Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Fix min/max dates when picker zone isn't UTC
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomka committed Nov 13, 2019
1 parent 1a7f907 commit 0576c01
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
18 changes: 6 additions & 12 deletions src/DatetimePopup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
<datetime-year-picker
v-if="step === 'year'"
@change="onChangeYear"
:min-date="minDatetimeUTC"
:max-date="maxDatetimeUTC"
:min-date="minDatetime"
:max-date="maxDatetime"
:year="year"></datetime-year-picker>
<datetime-month-picker
v-if="step === 'month'"
@change="onChangeMonth"
:min-date="minDatetimeUTC"
:max-date="maxDatetimeUTC"
:min-date="minDatetime"
:max-date="maxDatetime"
:year="year"
:month="month"></datetime-month-picker>
<datetime-calendar
Expand All @@ -25,8 +25,8 @@
:year="year"
:month="month"
:day="day"
:min-date="minDatetimeUTC"
:max-date="maxDatetimeUTC"
:min-date="minDatetime"
:max-date="maxDatetime"
:week-start="weekStart"
></datetime-calendar>
<datetime-time-picker
Expand Down Expand Up @@ -168,12 +168,6 @@ export default {
day: 'numeric'
})
},
minDatetimeUTC () {
return this.minDatetime ? this.minDatetime.toUTC() : null
},
maxDatetimeUTC () {
return this.maxDatetime ? this.maxDatetime.toUTC() : null
},
minTime () {
return (
this.minDatetime &&
Expand Down
4 changes: 2 additions & 2 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export function monthDays (year, month, weekStart) {
export function monthDayIsDisabled (minDate, maxDate, year, month, day) {
const date = DateTime.fromObject({ year, month, day, zone: 'UTC' })

minDate = minDate ? startOfDay(minDate) : null
maxDate = maxDate ? startOfDay(maxDate) : null
minDate = minDate ? startOfDay(minDate.setZone('UTC', { keepLocalTime: true })) : null
maxDate = maxDate ? startOfDay(maxDate.setZone('UTC', { keepLocalTime: true })) : null

return (minDate && date < minDate) ||
(maxDate && date > maxDate)
Expand Down

0 comments on commit 0576c01

Please sign in to comment.