timeControl calendar fixed #1623

This commit is contained in:
Joan Sanchez 2019-08-01 09:58:59 +02:00
parent 77d8ac82a5
commit 0a4e5dfe85
2 changed files with 16 additions and 8 deletions

View File

@ -260,8 +260,9 @@ export default class Calendar extends Component {
*/
moveNext(skip = 1) {
let next = this.defaultDate.getMonth() + skip;
this.defaultDate.setDate(1);
this.defaultDate.setMonth(next);
this.defaultDate.setHours(0, 0, 0, 0);
this.defaultDate.setDate(1);
this.repaint();
this.emit('moveNext');
@ -274,8 +275,11 @@ export default class Calendar extends Component {
*/
movePrevious(skip = 1) {
let previous = this.defaultDate.getMonth() - skip;
this.defaultDate.setDate(1);
this.defaultDate.setMonth(previous);
this.defaultDate.setHours(0, 0, 0, 0);
const lastDate = this.lastDay(this.defaultDate);
this.defaultDate.setDate(lastDate.getDate());
this.repaint();
this.emit('movePrevious');

View File

@ -84,7 +84,7 @@ class Controller {
for (let i = 0; i < weekdays.length; i++) {
const dated = new Date();
dated.setHours(0, 0, 0, 0);
dated.setHours(23, 59, 0, 0);
dated.setMonth(this.started.getMonth());
dated.setDate(this.started.getDate() + i);
@ -113,10 +113,10 @@ class Controller {
}
get weekOffset() {
const currentDate = this.defaultDate;
const weekDay = currentDate.getDay() + 1;
const timed = this.defaultDate;
const weekDay = timed.getDay() == 0 ? 7 : timed.getDay();
return weekDay - 2;
return weekDay - 1;
}
/**
@ -125,8 +125,10 @@ class Controller {
*/
get started() {
const started = new Date();
const offset = this.weekOffset;
started.setMonth(this.defaultDate.getMonth());
started.setDate(this.defaultDate.getDate() - this.weekOffset);
started.setDate(this.defaultDate.getDate() - offset);
started.setHours(0, 0, 0, 0);
return started;
@ -202,8 +204,10 @@ class Controller {
onSelection(value) {
const selected = value[0].dated;
this.defaultDate.setMonth(selected.getMonth());
this.defaultDate.setDate(selected.getDate() - 1);
this.defaultDate.setDate(selected.getDate());
this.refresh();
}