datetime - Weird flex date issue -


Flex is driving me crazy and I think it's a wonderful collection of how it controls leap years and there is no leap year. So here is my example. I have a date date method that finds the number of days or milliseconds between two dates. If I run the following three statements, then I get some strange issues.

  dateDiff ("Date", New Date (2010, 0,1), New Date (2010, 0, 31)); DateDiff ("Date", New Date (2010, 1,1), New Date (2010, 1, 28)); DateDiff ("Date", New Date (2010, 2,1), New Date (2010, 2, 31)); DateDiff ("Date", New Date (2010, 3,1), New Date (2010, 3, 30));  

If you want to see the date of comparison above, you are expected to get the number of days between 30, 27, 30, 29 dates. The strange thing about me is that compared to 1 October to 31 March, I get 29. Why is it like this? What is there to be only 28 days in February? If anyone has any input on this which would be highly appreciated.

  Public stable work date def (datepart: string, start date: date, expiry date: date): number {var _ returnurn: number = 0; Switch (datepart) {case "milliseconds": _ rattan value = enddate. Time - StartDate Time; break; Case "Date": // TODO: DST needs to detect the problem, ie 23 hours on DST startup, finally 25 // Math.floor starts with the DST rounding the error with DST starts after you; _firvail = Math Floor (Detection ("milliseconds", start date, end date) / (1000 × 60 * 60 * 24)); break; } Return _ Ratings; This is not a leap year problem, but a daylight saving time problem.  

To correct code in DST account , You have to consider the timeoffice for both dates to determine whether the date range has reached a DST boundary.

  var Adjustment: Number = (StartedTimeZone Offset - End dateTimeZone Offset) * 60 * 1000; _Ratanvalue = AndDet Time - StartDate Time + adjustment;  

It will find a difference between two time zones (in minutes), convert that value to milliseconds, and then the timezone difference for the difference of milliseconds for "cancel" the DST boundary. apply the .

Naturally, when both numbers are in the same time zone, the adjustment value becomes 0 and time values ​​are not adjusted.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -