Closed Bug 61184 Opened 20 years ago Closed 16 years ago

(Mac-only): Date.prototype.toLocale___String() functions : GMT error

Categories

(Core :: JavaScript Engine, defect, P3)

PowerPC
Mac System 9.x
defect

Tracking

()

RESOLVED WORKSFORME
Future

People

(Reporter: pschwartau, Assigned: beard)

Details

(Keywords: intl)

Attachments

(2 files)

On my Mac, I am getting a GMT discrepancy for the date 

                 'Sun Dec 31 16:00:00 GMT-0800 1899' 


The toLocale___String() functions differ from the to____String() functions.
This does not happen on my WinNT or Linux boxes. This is causing the following
date tests to fail on the Mac: 


                  js/tests/ecma_3/Date/15.9.5.5.js
                  js/tests/ecma_3/Date/15.9.5.6.js
                  js/tests/ecma_3/Date/15.9.5.7.js





ON THE MAC (note the 8-hour discrepancies) :

js> d = new Date('Sun Dec 31 16:00:00 GMT-0800 1899') 
Sun Dec 31 16:00:00 GMT-0800 1899 

js> d.toString() 
Sun Dec 31 16:00:00 GMT-0800 1899 
js> d.toLocaleString() 
Monday January 01 00:00:00 1900 
 
js> d.toDateString() 
Sun Dec 31 1899 
js> d.toLocaleDateString() 
Monday January 01 1900 

js> d.toTimeString() 
16:00:00 GMT-0800 
js> d.toLocaleTimeString() 
00:00:00 



COMPARE ON WINNT (no discrepancies) :

js> d = new Date('Sun Dec 31 16:00:00 GMT-0800 1899')
Sun Dec 31 16:00:00 GMT-0800 (Pacific Standard Time) 1899

js> d.toString()
Sun Dec 31 16:00:00 GMT-0800 (Pacific Standard Time) 1899
js> d.toLocaleString()
Sunday, December 31, 1899 16:00:00

js> d.toDateString()
Sun Dec 31 1899
js> d.toLocaleDateString()
Sunday, December 31, 1899

js> d.toTimeString()
16:00:00 GMT-0800 (Pacific Standard Time)
js> d.toLocaleTimeString()
16:00:00



Compare bug 45590, "Date.toGMTString() is 24 hours fast" (on the Mac). 
However, I think this bug is a separate issue -
Phil - Does the above patch fix the problem?

Mike
It fixed the error I reported, but now I get these errors (on Mac):


*-* Testcase ecma_3/Date/15.9.5.5.js failed: Failure messages were: 

Math.abs(Date.parse(now.toLocaleString()) - now.valueOf()) < 1000 = false 
FAILED! expected: true 
Date.parse(Wed Dec 31 16:00:00 GMT-0800 1969).toLocaleString()) = 28800000 
FAILED! expected: 0 
Date.parse(Wed Dec 31 08:00:00 GMT-0800 1969).toLocaleString()) = 0 FAILED! 
expected: -28800000 
Date.parse(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleString()) = -2208960000000 
FAILED! expected: -2208988800000 
Date.parse(Mon Jan 01 00:00:00 GMT-0800 1900).toLocaleString()) = -2208931200000 
FAILED! expected: -2208960000000 
Date.parse(Fri Dec 31 16:00:00 GMT-0800 1999).toLocaleString()) = 946713600000 
FAILED! expected: 946684800000 
Date.parse(Sat Jan 01 00:00:00 GMT-0800 2000).toLocaleString()) = 946742400000 
FAILED! expected: 946713600000 
Date.parse(Mon Feb 28 16:00:00 GMT-0800 2000).toLocaleString()) = 951811200000 
FAILED! expected: 951782400000 
Date.parse(Mon Feb 28 15:59:59 GMT-0800 2000).toLocaleString()) = 951811199000 
FAILED! expected: 951782399000 
Date.parse(Tue Feb 29 00:00:00 GMT-0800 2000).toLocaleString()) = 951840000000 
FAILED! expected: 951811200000 
Date.parse(Fri Dec 31 16:00:00 GMT-0800 2004).toLocaleString()) = 1104566400000 
FAILED! expected: 1104537600000 
Date.parse(Fri Dec 31 15:59:59 GMT-0800 2004).toLocaleString()) = 1104566399000 
FAILED! expected: 1104537599000 
Date.parse(Sat Jan 01 00:00:00 GMT-0800 2005).toLocaleString()) = 1104595200000 
FAILED! expected: 1104566400000 


*-* Testcase ecma_3/Date/15.9.5.6.js failed: Failure messages were: 

(Date.parse(now.toLocaleDateString()) - (midnight(now)).valueOf()) == 0 = false 
FAILED! expected: true 
Date.parse(Wed Dec 31 16:00:00 GMT-0800 1969).toLocaleDateString()) = 28800000 
FAILED! expected: -57600000 
Date.parse(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleDateString()) = 
-2208960000000 FAILED! expected: -2209046400000 
Date.parse(Fri Dec 31 16:00:00 GMT-0800 1999).toLocaleDateString()) = 
946713600000 FAILED! expected: 946627200000 
Date.parse(Mon Feb 28 16:00:00 GMT-0800 2000).toLocaleDateString()) = 
951811200000 FAILED! expected: 951724800000 
Date.parse(Fri Dec 31 16:00:00 GMT-0800 2004).toLocaleDateString()) = 
1104566400000 FAILED! expected: 1104480000000 


*-* Testcase ecma_3/Date/15.9.5.7.js failed: Failure messages were: 

(Wed Dec 31 16:00:00 GMT-0800 1969).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
(Wed Dec 31 08:00:00 GMT-0800 1969).toLocaleTimeString() = 16:00:00 
FAILED! expected: 08:00:00 
(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
(Mon Jan 01 00:00:00 GMT-0800 1900).toLocaleTimeString() = 08:00:00 
FAILED! expected: 00:00:00 
(Fri Dec 31 16:00:00 GMT-0800 1999).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
(Sat Jan 01 00:00:00 GMT-0800 2000).toLocaleTimeString() = 08:00:00 
FAILED! expected: 00:00:00 
(Mon Feb 28 16:00:00 GMT-0800 2000).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
(Mon Feb 28 15:59:59 GMT-0800 2000).toLocaleTimeString() = 23:59:59 
FAILED! expected: 15:59:59 
(Tue Feb 29 00:00:00 GMT-0800 2000).toLocaleTimeString() = 08:00:00 
FAILED! expected: 00:00:00 
(Wed Nov 29 20:30:25 GMT-0800 2000).toLocaleTimeString() = 04:30:25 
FAILED! expected: 20:30:25 
(Thu Nov 30 04:30:25 GMT-0800 2000).toLocaleTimeString() = 12:30:25 
FAILED! expected: 04:30:25 
(Fri Dec 31 16:00:00 GMT-0800 2004).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
(Fri Dec 31 15:59:59 GMT-0800 2004).toLocaleTimeString() = 23:59:59 
FAILED! expected: 15:59:59 
(Sat Jan 01 00:00:00 GMT-0800 2005).toLocaleTimeString() = 08:00:00 
FAILED! expected: 00:00:00 
I'm sorry, I see that "Sun Dec 31 16:00:00 GMT-0800 1899" date in the new 
errors, too. It looks like the patch has not corrected the problem with
the reported date; plus now we're getting problems with all the other dates...
If I revert jsdate.c back to the way it originally was, here are the results:



*-* Testcase ecma_3/Date/15.9.5.5.js failed: Failure messages were: 

Date.parse(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleString()) = -2208960000000 
FAILED! expected: -2208988800000 


*-* Testcase ecma_3/Date/15.9.5.6.js failed: Failure messages were: 

Date.parse(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleDateString()) = 
-2208960000000 FAILED! expected: -2209046400000 


*-* Testcase ecma_3/Date/15.9.5.7.js failed: Failure messages were: 

(Sun Dec 31 16:00:00 GMT-0800 1899).toLocaleTimeString() = 00:00:00 
FAILED! expected: 16:00:00 
Quick note...

The output of any of the Date.prototype.toLocale functions aren't guaranteed to
be parsable, and might vary from OS to OS.  (But it looks like you're getting
good results on some OSes.)
The failure dates on the Mac are before 1900, outside the Mac 1904->? domain.

Mapping earlier dates to equivalent dates in the 1970-20?? range (mac- and
32-bit-unix- conservative) before asking the OS for info might fix it.
Hey, I wonder if Beard's rework of the Mac aspects of prmjtime.c fixed this. 
Phil, could you check?

Thanks -
Mike
No, I'm still getting the same Mac results as in the original report -
Reassigning Mike's JS Engine bugs to Patrick, as per recent meeting - 
Assignee: mike+mozilla → beard
Marking future.
Target Milestone: --- → Future
Summary: Date.prototype.toLocale___String() functions : GMT error → (Mac-only): Date.prototype.toLocale___String() functions : GMT error
This bug is targeted at a Mac classic platform/OS, which is no longer supported
by mozilla.org. Please re-target it to another platform/OS if this bug applies
there as well or resolve this bug.

I will resolve this bug as WONTFIX in four weeks if no action has been taken.
To filter this and similar messages out, please filter for "mac_cla_reorg".
Keywords: intl
WFM Moz OSX.
Mac CFM RIP.
Status: NEW → RESOLVED
Closed: 16 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.