Open smthpickboy opened 8 years ago
Well, there are 2 problems. No.1 is #1743 No.2 is UTC conversion bug.
If only No.2 is fixed, No.1 will still cause "endDate" problem for GMT-0X00 time zones and similarly "startDate" problems for GMT+0X00 time zones.
Code from 1.6.0: _utc_to_local: function(utc){ return utc && new Date(utc.getTime() + (utc.getTimezoneOffset()_60000)); }, _local_to_utc: function(local){ return local && new Date(local.getTime() - (local.getTimezoneOffset()_60000)); }
This is simply wrong. For example:
var local = new Date();
Gives me:Fri Apr 29 2016 17:41:40 GMT+0800
But, according to _local_to_utc code,new Date(local.getTime() - (local.getTimezoneOffset()*60000));
result inSat Apr 30 2016 01:41:40
which is wrong. The correct time should beFri Apr 29 2016 09:41:40 GMT+0800
So, conclusion: _utc_to_local and _local_to_utc should swap their names
If you just convert time back and forth, this won't be a big problem, you can always get back your original local time , since those 2 conversion are mirrored.
But, this can result in a serious problem, regarding
1743
If you set
endDate: "0d"
option, which means you can only select dates up to today. ButdateWithinRange
are checked against UTC time, while startDate/endDate are checked against local time. So when you are trying to set initial date of datepicker to today, such as$('#inputDate').datepicker("setDate", new Date());
It just won't work when my local time is after 16:00, because the bugged _local_to_utc will convert UTC date to tomorrow, so it fails the check ofdateWithinRange
.