Date & daylight savings

Date class has a bug related to the daylight savings.

If you want to change the date using number of seconds it will cause a problem going over the dates when daylight savings change.

E.g.


private var mydate:Date = new Date(2008, 3, 4, 0, 0, 0, 0);

mydate = new Date (mydate.getTime() + 1000 * 60 * 60 * 24)

mydate = new Date(mydate);

If it goes over the date when daylight savings is changed, instead of adding 24 hours it will add 23 or 25 hours (depending on the time of the year – summer or winter)

So, to do perform Date manipulation correctly you have to use date field, i.e.:

mydate.date +=1;

This method correctly handles the daylight savings and it will keep initial 00:00:00 time.

PS https://bugs.adobe.com/jira/browse/SDK-14983

Leave a Reply