I have some C# web services that return JSON. The .NET JavaScriptSerializer returns dates in Epoch Time (milliseconds since 1970). On any Windows machine, the web based application processes the milliseconds back into the proper date without a problem.
On my Mac, the dates are sometimes off by 1 hour. Not every time. Only sometimes. This is now happening on the iPhone front end I'm building as well.
I thought at first that I had lost some precision when dividing the milliseconds by 1000 to create a valid Objective-C NSDate object. Then I tested date creation in javascript on Mac Firefox with the same timestamp and got the same 1 hour offset.
Any ideas? Thanks...
Edit: I also noticed in the Console in XCode that the date created had a -4 or -5 next to it. I'm assuming that is a GMT offset. Those seem to vary independent of whether or not the date is offset by 1 hour. So some -4 dates and some -5 dates are correct and some of either one are offset.
Edit: Examples using:
console.log(new Date(-1173643200000));
returns Sun Oct 23 1932 00:00:00 GMT-0400 (EST)
console.log(new Date(-1031515200000));
returns Sat Apr 24 1937 23:00:00 GMT-0500 (EST)
NSDate* date = [NSDate dateWithTimeIntervalSince1970:ticks / 1000];
-589320000000 = 1951-04-30 00:00:00 -0400
-1173643200000 = 1932-10-22 23:00:00 -0500 (This one returns correct in Firebug Console, wrong in XCode Console)
-1303416000000 = 1928-09-12 00:00:00 -0400
-1492545600000 = 1922-09-15 00:00:00 -0400
-1263668400000 = 1929-12-16 00:00:00 -0500
-1252094400000 = 1930-04-29 00:00:00 -0400
-1046458800000 = 1936-11-03 00:00:00 -0500
-1298746800000 = 1928-11-05 00:00:00 -0500
-1031515200000 = 1937-04-24 23:00:00 -0500 (Returns wrong in both Firebug Console and XCode Console)
-910465200000 = 1941-02-24 00:00:00 -0500
-1152648000000 = 1933-06-23 00:00:00 -0400
-1109793600000 = 1934-10-31 23:00:00 -0500
Is it possible that Microsoft/Mozilla/Apple have conflicting rules defining when Daylight Saving Time started back then?
Edit: Mac Firefox and Windows Firefox get different results for -1031515200000. Both machines are set to the same timezone.