Closed Bug 2183 Opened 26 years ago Closed 15 years ago

windows localtime() bug exposed in javascript Date object

Categories

(Core :: JavaScript Engine, defect, P5)

x86
Windows NT
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: mike+mozilla, Assigned: jlewinsohn)

References

()

Details

Attachments

(1 file)

From: "Richard M. Smith" <rms@pharlap.com> Subject: The "April Fools Y2K" bug and JavaScript To: jfriend@netscape.com Hi John, JavaScript has a pretty ugly Y2K bug thanks to Visual C++. The localtime() function in the Visual C++ runtime library gets the wrong start date for daylight savings time in the year 2001. Therefore all time values from April 1 thru April 7, 2001 are displayed incorrectly in JavaScript. (Windows 98 however gets the DST start date right). I found this "April Fools Y2K" bug this afternoon at work and just built a JavaScript test case for it now: document.writeln(new Date(0x3AC796D0 * 1000), "<br>"); document.writeln(new Date(0x3ACF2B70 * 1000), "<br>"); document.writeln(new Date(0x3AD06EE0 * 1000), "<br>"); outputs under Nav 4.5: Sun Apr 01 16:00:00 GMT-0500 (Eastern Standard Time) 2001 Sat Apr 07 10:00:00 GMT-0500 (Eastern Standard Time) 2001 Sun Apr 08 10:00:00 GMT-0400 (Eastern Daylight Time) 2001 IE4 gets the same wrong answers. The rule for the USA is that DST starts on the first Sunday in April. As you can see, JavaScript says that April 1, 2001 is still on standard time. I've already informed Microsoft of the problem. This is going to be a huge mess because anyone who uses Visual C++ and calls the localtime() function is going to have to do a rev of their software. The VC++ bug seems to appear in any year in which April 1 falls on a Sunday. The last time this happened was in 1990. Richard .... I have verified that this problem appears with our current javascript engine under NT. The cleanest solution to this problem would be to build against a patched version of the C libraries, or perhaps to direct the user to such a patch if we link against the libraries dynamically.
added CCs
added CCs
More comments from Richard Smith - Hi Mike, I just built my APRIL1.C test program for the April Fools 2001 bug with all versions of VC++ from version 2 to version 6. Looks like the bug was introduced in version 4.1. I believe that VC++ 4.1 started shipping late summer 1996. Attached is the results of my testing. Richard ================================================================ vc2 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 17:00:00 EDT -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 11:00:00 EDT -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc4 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 17:00:00 EDT -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 11:00:00 EDT -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc41 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc42 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc5 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc6 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ Here is the build.bat file: call vc2 cl -Fea1vc2 april1.c call vc4 cl -Fea1vc4 april1.c call vc41 cl -Fea1vc41 april1.c call vc42 cl -Fea1vc42 april1.c call vc5 cl -Fea1vc5 april1.c call vc6 cl -Fea1vc6 april1.c
More comments from Richard Smith - Hi Mike, I just built my APRIL1.C test program for the April Fools 2001 bug with all versions of VC++ from version 2 to version 6. Looks like the bug was introduced in version 4.1. I believe that VC++ 4.1 started shipping late summer 1996. Attached is the results of my testing. Richard ================================================================ vc2 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 17:00:00 EDT -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 11:00:00 EDT -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc4 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 17:00:00 EDT -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 11:00:00 EDT -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc41 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc42 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc5 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ vc6 ================================================================ 0x3AC796D0 = Sunday, April 1, 2001 -- 16:00:00 EST -- DOY=90 0x3ACF2B70 = Saturday, April 7, 2001 -- 10:00:00 EST -- DOY=96 0x3AD06EE0 = Sunday, April 8, 2001 -- 10:00:00 EDT -- DOY=97 ================================================================ Here is the build.bat file: call vc2 cl -Fea1vc2 april1.c call vc4 cl -Fea1vc4 april1.c call vc41 cl -Fea1vc41 april1.c call vc42 cl -Fea1vc42 april1.c call vc5 cl -Fea1vc5 april1.c call vc6 cl -Fea1vc6 april1.c
Status: NEW → ASSIGNED
Added norris to cc: list
Setting all current Open/Normal to M4.
per leger, assigning QA contacts to all open bugs without QA contacts according to list at http://bugzilla.mozilla.org/describecomponents.cgi?product=Browser
Priority: P2 → P5
Target Milestone: M4 → M7
Setting to M7 until I have a better way to get this off the milestone radar. This is not strictly our bug; I'm keeping it around to point to if anyone ever blames us for the bug in the windows C runtime that causes this... and also as a reminder to myself that I need to check in a javascript testcase for it.
Target Milestone: M7 → M15
Setting to m15. I still want it way off the radar. Also de-cc-ing Norris.
Component: JavaScript → Javascript Engine
moving to the "JavaScript Engine" component.
Note to self. This should probably be a release note.
Target Milestone: M15 → M20
Moving to m20. It's still a placeholder bug.
Setting all Javacript bugs to rginda QA Contact.
QA Contact: cbegle → rginda
The day has come and gone... Marking as WONTFIX.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → WONTFIX
Verified wontfix.
Status: RESOLVED → VERIFIED
Clocks in Europe went forward this week, and Win32 API agrees with me. But MSVCRT doesn't :-(
Status: VERIFIED → REOPENED
Resolution: WONTFIX → ---
Um.. so are we supposed to reimplement the C lib's functionality just because? WONTFIX sorta means "we know it's a bug, and we don't plan to do anything", no?
I must be missing something. This bug was filed on WinNT; I'm on WinNT; but if I change my system timezone to East Coast time and load the testcase, I do not see the bug. I have WinNT 4.0(SP6) I've added a line for March 31, 2001 for more context. The original report above says IE and Mozilla output this: Sat Mar 31 2001 10:00:00 GMT-0500 (Eastern Standard Time) Sun Apr 01 2001 16:00:00 GMT-0500 (Eastern Standard Time) <--- WRONG Sat Apr 07 2001 10:00:00 GMT-0500 (Eastern Standard Time) <--- WRONG Sun Apr 08 2001 10:00:00 GMT-0400 (Eastern Daylight Time) But what I'm getting in Mozilla (and IE) is: Sat Mar 31 2001 10:00:00 GMT-0500 (Eastern Standard Time) Sun Apr 01 2001 17:00:00 GMT-0400 (Eastern Daylight Time) Sat Apr 07 2001 11:00:00 GMT-0400 (Eastern Daylight Time) Sun Apr 08 2001 10:00:00 GMT-0400 (Eastern Daylight Time) Everything looks correct, doesn't it? Am I missing something? Neil, what Windows OS are you running?
Assignee: mike+mozilla → khanson
Status: REOPENED → NEW
QA Contact: rginda → pschwartau
Note bug 127246: you have to actually restart Mozilla after changing your Windows timezone, in order to see any effect. I am doing that for greater ease of comparison, since the original data above came from the East Coast timezone.
I'll see if I can find time to write a test case for my time zone.
Reassigning -
Assignee: khanson → date
FWIW, on WinXP2 FF Trunk Sat Mar 31 2001 10:00:00 GMT-0500 (Eastern Standard Time) Sun Apr 01 2001 17:00:00 GMT-0400 (Eastern Standard Time) Sat Apr 07 2001 11:00:00 GMT-0400 (Eastern Standard Time) Sun Apr 08 2001 10:00:00 GMT-0400 (Eastern Standard Time) MSIE6 Sat Mar 31 10:00:00 EST 2001 Sun Apr 1 17:00:00 EDT 2001 Sat Apr 7 11:00:00 EDT 2001 Sun Apr 8 10:00:00 EDT 2001
Blocks: 285663
not to self: you must fix this bug asap please! change c library function 'localtime()' to suit and fix date problem. version compatibility check! Sat Mar 31 2001 10:00:00 GMT-1900 (Eastern Standard Time) Sun Apr 01 2001 19:00:00 GMT-1900 (Eastern Standard Time) Sat Apr 07 2001 10:00:00 GMT-1900 (Eastern Standard Time) Sun Apr 08 2001 23:00:00 GMT-1900 (Eastern Daylight Time)
Assignee: date → jlewinsohn
QA Contact: pschwartau → general
If this was decided as a WONTFIX in 2000 then it's even more of a WONTFIX in 2009.
Status: NEW → RESOLVED
Closed: 24 years ago15 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: