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,
},
}
}
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);
}
}]
},
Most helpful comment
It's working for me.
http://jsfiddle.net/cinwell_li/0ug0ome5/1/