diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index 372ed280d..e7c925e60 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -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'); diff --git a/modules/worker/front/time-control/index.js b/modules/worker/front/time-control/index.js index 2d23d378c..b013df44b 100644 --- a/modules/worker/front/time-control/index.js +++ b/modules/worker/front/time-control/index.js @@ -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(); }