Closed Bug 11234 Opened 27 years ago Closed 25 years ago

new Date( Date.toLocaleString() ) fails to return the original date

Categories

(Core :: JavaScript Engine, defect, P2)

x86
Windows NT
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: cbegle, Assigned: mike+mozilla)

References

()

Details

(This bug imported from BugSplat, Netscape's internal bugsystem. It was known there as bug #111818 http://scopus.netscape.com/bugsplat/show_bug.cgi?id=111818 Imported into Bugzilla on 08/04/99 01:40) according to 15.9.3.8, passing a string to the date constructor should parse the string as in date.parse. however, parsing a string created by Date.toLocaleString() fails to return the same date that the localeString came from. // this is correct js> new Date(PST_FEB_29_2000) Tue Feb 29 00:00:00 GMT-0800 (PST) 2000 // shouldnt' this be 00:00:00 ? js> (new Date(PST_FEB_29_2000)).toLocaleString() February 29, 2000 12:00:00 AM PST // off by 12 hours! js> new Date(Date.parse((new Date(PST_FEB_29_2000)).toLocaleString())) Tue Feb 29 12:00:00 GMT-0800 (PST) 2000 // also off by 12 hours js> new Date((new Date(PST_FEB_29_2000)).toLocaleString()) Tue Feb 29 12:00:00 GMT-0800 (PST) 2000
Status: NEW → ASSIGNED
Reviving fossil Bugzilla bugs. Marking as assigned.
Status: ASSIGNED → RESOLVED
Closed: 25 years ago
Resolution: --- → FIXED
Marking as fixed. First, we don't guarantee a roundtrip from toLocaleString... Second, it looks like there was a problem with parsing 12:00 AM; bug 4088 fixed that some months ago. That also fixed our behaviour here, I think. Some transcripts: Linux - js> d = new Date('Tue Feb 29 00:00:00 GMT-0800 (PST) 2000') Tue Feb 29 00:00:00 GMT-0800 (PST) 2000 js> d.toLocaleString() Tue Feb 29 00:00:00 2000 js> d = new Date('February 29, 2000 12:00:00 AM PST') Tue Feb 29 00:00:00 GMT-0800 (PST) 2000 Windows NT 4.0 js> d = new Date('Tue Feb 29 00:00:00 GMT-0800 (PST) 2000') Tue Feb 29 00:00:00 GMT-0800 (Pacific Standard Time) 2000 js> d.toLocaleString() Tuesday, February 29, 2000 00:00:00 js> d2 = new Date(d.toLocaleString()) Tue Feb 29 00:00:00 GMT-0800 (Pacific Standard Time) 2000 js> d3 = new Date('February 29, 2000 12:00:00 AM PST') Tue Feb 29 00:00:00 GMT-0800 (Pacific Standard Time) 2000 ... so it looks like things are groovey.
You need to log in before you can comment on or make changes to this bug.