bootstrap
bootstrap copied to clipboard
Duplicate day in datepicker popup
Bug description: There is a duplicate day 15 in datepicker popup. I attach a imagem from the problem.
Angular: v1.5.8 UIBS: v2.01, Bootstrap: 3.3.7
Image is not enough to diagnose and eventually fix the problem. Please provide a proper issue report: https://github.com/angular-ui/bootstrap/blob/master/CONTRIBUTING.md#you-think-youve-found-a-bug
I did this sample: http://plnkr.co/edit/6DXvOYk8PKfTUYKWEpB9
The problem occurs after you select the date and open the datapicker for the second time and you need be at brazilian timezone.
I think the problem is because on the October, 15 will begin summer time and the clock back one hour
apologize for my english
This sounds like a subtle issue, and not sure if it's one we will be able to fix due to the flaw of our use of date models in the datepicker :( .
The workaround is to pick a time for the date model for the particular timezone that would avoid this problem when accounting for the offset...not great, but adequate and likely the best option.
Just reporting. I made some tests with angular-bootstrap version 0.14.3 and , and this problem persists only in the firefox.
As can be seeing here the firefox handle the initial day of daylight saving time going back in one hour. In the brazilian case, as the ligth saving start at midnight, it makes firefox go back to the 23 hours of the last day.
This will happen every time you use
new Date(Y,M,D)
without using a valid hour as suggested as workaround by @wesleycho.
If you compare the way chrome and firefox handle the data, you will notice some wierd things:
Whit Chrome:
new Date(2017,9,14) -> Sat Oct 14 2017 00:00:00 GMT-0300 (Hora oficial do Brasil)
new Date(2017,9,15) -> Sun Oct 15 2017 01:00:00 GMT-0200 (Horário brasileiro de verão)
new Date(2017,9,15).toString() -> "Sun Oct 15 2017 01:00:00 GMT-0200 (Horário brasileiro de verão)"
Whit Firefox: new Date(2017,9,14) -> Date 2017-10-14T03:00:00.000Z new Date(2017,9,15)-> Date 2017-10-15T02:00:00.000Z new Date(2017,9,15).toString() -> "Sat Oct 14 2017 23:00:00 GMT-0300 (Hora oficial do Brasil)"`
I debugged the _refreshView function at ui-bootstrap-tpls.js and saw that the day[i] object was created with two 14 in the label.
Object { date: Date 2017-10-14T03:00:00.000Z, label: "14", ..., uid: "datepicker-2182-5916-13" } Object { date: Date 2017-10-15T02:00:00.000Z, label: "14", ..., uid: "datepicker-2182-5916-14" } Object { date: Date 2017-10-16T01:00:00.000Z, label: "15", ..., uid: "datepicker-2182-5916-15" }
Probably it is a problem whit the 'dateFilter' from angular that is used to generate the label.
Do not let the numbers shown in the date field above deceive you. 2017-10-16T01:00:00.000Z applying the Brazil time zone (-3) is actually 2017-10-15T22:00:00. Probably because this the label become "15" and we have two 14. One in the 0 hour and the second with 23.
In my case (using version 0.14.3) I get the calendar rendered right just adding to my model value any time greater or equal to one.
Here is the bug reported in the Firefox site about this behavior: 1392657 marked as duplicate of 830304 Opened 5 years ago, and don't seems to be corrected any time soon.
Any way, I don't believe that any line of code should be changed in the angular-ui because of that.
Maybe will be easiest talk to Brazil president to change the starting time of the daylight saving.