Element: Bug? Datepicker. If firstDayOfWeek is not 7, picker highlight wrong date

Created on 28 Feb 2017  ·  3Comments  ·  Source: ElemeFE/element

Hello!
ElementUI version
1.2.1
Vue version
2.1.8

Problem in datepicker with type=daterange (only).

I set the "firstDayOfWeek" as 1 (monday) and find a problem.
Datepicker highlights days with 1 day offset (if firstDayOfWeek=2, offset in datepicker grows to 2 days etc.).
But date in input is correct, problem is in visual part of datepicker only.

Is this a my local problem (config and bad code) or bug?

Screenshot:
https://yadi.sk/i/HEOJLlj73EkXtg

My code:

<el-date-picker
                        v-model="form.period"
                        type="daterange"
                        :picker-options="dateRangeOptions1"
                        placeholder="Pick a day">
                </el-date-picker>
data() {
            return {
                dateRangeOptions1: {
                    firstDayOfWeek: 1,
                },
         }
}
repro

Most helpful comment

All 3 comments

This can be reproduced if supplied period contains string values which cannot be properly instantiated by new Date, for example new Date('2017-03-01') would actually yield Tue Feb 28 2017 19:00:00 GMT-0500 (EST) (depends on locale, and timezone, etc, but you get the idea); while new Date('2017-03-01 00:00:00') would yield Wed Mar 01 2017 00:00:00 GMT-0500 (EST)

Laziest way to work around this is to wrap supplied string dates using moment

EDIT: this in my opinion has nothing to do with firstDayOfWeek setting

I also can reproduce the issue.
In my case, I set firstDayOfWeek to 3.
if I navigate month to current month, it will select a date different what i click. that's a week after.
If I navigate to other month, it works properly.

I paste the options
dayPickerOptions: {
disabledDate(time) {
return time.getTime() - Date.now() > 3600 * 1000 * 24 * 60;
},
firstDayOfWeek: 3,
shortcuts: [{
text: 'Today',
onClick(picker) {
picker.$emit('pick', new Date());
}
}, {
text: 'Week After',
onClick(picker) {
const date = new Date();
date.setTime(date.getTime() - 3600 * 1000 * 24);
picker.$emit('pick', date);
}
}]
},

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akaylh picture akaylh  ·  3Comments

gengxuelei picture gengxuelei  ·  3Comments

fscardua picture fscardua  ·  3Comments

no5no6 picture no5no6  ·  3Comments

sudo-suhas picture sudo-suhas  ·  3Comments