Closed
Bug 58008
Opened 26 years ago
Closed 26 years ago
ECMA Conformance: missing Date.to[Locale](Date|Time)String() functions
Categories
(Rhino Graveyard :: Core, defect, P3)
Rhino Graveyard
Core
Tracking
(Not tracked)
VERIFIED
FIXED
People
(Reporter: david, Assigned: mike+mozilla)
Details
Attachments
(2 files)
|
7.27 KB,
patch
|
Details | Diff | Splinter Review | |
|
9.68 KB,
patch
|
Details | Diff | Splinter Review |
The latest rhinoTip, "rhino15R2pre" does not implement four Date methods:
toDateString(), toTimeString(), toLocaleDateString() and toLocaleTimeString().
See ECMA v3 spec, sections 15.9.5.3 to 15.9.5.7
Note that this bug also exists in Spidermonkey. See bug #58007.
Comment 1•26 years ago
|
||
Confirming with Rhino built on WinNT 2000-10-25. Here are the ECMA sections:
15.9.5.3 Date.prototype.toDateString ( )
This function returns a string value. The contents of the string are
implementation-dependent, but are intended to represent the “date” portion
of the Date in the current time zone in a convenient, human-readable form.
15.9.5.4 Date.prototype.toTimeString ( )
This function returns a string value. The contents of the string are
implementation-dependent, but are intended to represent the “time” portion
of the Date in the current time zone in a convenient, human-readable form.
15.9.5.6 Date.prototype.toLocaleDateString ( )
This function returns a string value. The contents of the string are
implementation-dependent, but are intended to represent the “date” portion
of the Date in the current time zone in a convenient, human-readable form
thatcorresponds to the conventions of the host environment’s current locale.
NOTE The first parameter to this function is likely to be used in a future
version of this standard; it is recommended that implementations do not use
this parameter position for anything else.
15.9.5.7 Date.prototype.toLocaleTimeString ( )
This function returns a string value. The contents of the string are
implementation-dependent, but are intended to represent the “time” portion
of the Date in the current time zone in a convenient, human-readable form that
corresponds to the conventions of the host environment’s current locale.
NOTE The first parameter to this function is likely to be used in a future
version of this standard; it is recommended that implementations do not use
this parameter position for anything else.
Updated•26 years ago
|
Status: NEW → ASSIGNED
Comment 2•26 years ago
|
||
The spec just says that it is basically implementation defined.
So for a Date d with
d.toString() == "Thu Oct 26 11:10:05 GMT-0400 (EDT) 2000"
should we have
d.toDateString() == "Thu Oct 26 2000"
and
d.toTimeString() == "11:10:05 GMT-0400 (EDT)"
and similarly for toLocaleDateString and toLocaleTimeString?
| Reporter | ||
Comment 3•26 years ago
|
||
I hate to say this, but I'd like it if the implementation-dependent behavior
of Rhino and Spidermonkey just happened to match whatever it is that
JScript does, assuming Microsoft has implemented these functions in IE 5.5
(I don't have a copy, or I'd check on this myself.)
Also, my intuition is that it is not useful to include the timezone in
the output of toTimeString(). Since the method explicitly returns a time in the
current time zone, I'd leave out the specification of the time zone.
Comment 5•26 years ago
|
||
The intent of the committee was that toDateString and toTimeString together
should provide the same information as toString. The descriptions state "in the
current time zone" because the description of toString states "in the current
time zone" to distinguish the output from that of toUTCString. The output of
toString must include the time zone for two reasons:
1. The standard requires Date.parse to round-trip (15.9.4.2) both toString and
toUTCString-generated strings.
2. Times close to the fall time change from daylight savings time to standard
time cannot be represented without using the time zone.
As such, toTimeString should include the time zone as well.
| Assignee | ||
Comment 6•26 years ago
|
||
| Assignee | ||
Comment 7•26 years ago
|
||
For this (or similar) script
d =new Date();
print(
'\ntoString: ' + d.toString() +
'\ntoGMTString: ' + d.toGMTString() +
'\ntoLocaleString: ' + d.toLocaleString() +
'\ntoLocaleDateString: ' + d.toLocaleDateString() +
'\ntoLocaleTimeString: ' + d.toLocaleTimeString() +
'\ntoDateString: ' + d.toDateString() +
'\ntoTimeString: ' + d.toTimeString())
ie output:
toString: Tue Oct 31 16:26:23 PST 2000
toGMTString: Wed, 1 Nov 2000 00:26:23 UTC
toLocaleString: Tuesday, October 31, 2000 4:26:23 PM
toLocaleDateString: Tuesday, October 31, 2000
toLocaleTimeString: 4:26:23 PM
toDateString: Tue Oct 31 2000
toTimeString: 16:26:23 PST
monkey output:
toString: Tue Oct 31 09:41:40 GMT-0800 (PST) 2000
toGMTString: Tue, 31 Oct 2000 17:41:40 GMT
toLocaleString: Tue Oct 31 09:41:40 2000
toLocaleDateString: 10/31/00
toLocaleTimeString: 09:41:40
toDateString: undefined // Tue Oct 31 2000
toTimeString: undefined // 09:41:40 GMT-0800 (PST)
rhino output:
toString: Wed Nov 01 06:19:24 GMT-0800 (PST) 2000
toGMTString: Wed, 01 Nov 2000 14:19:24 GMT
toLocaleString: November 1, 2000 6:19:24 AM PST
toLocaleDateString: November 1, 2000
toLocaleTimeString: 6:19:24 AM PST
toDateString: Wed Nov 01 2000
toTimeString: 06:19:24 GMT-0800 (PST)
Locale output is all over the map, but toDateString and toTimeString parallels
the toString format. We add GMT-0800 (which ie lacks) to ensure parsability in
the absence of cross-platform tables for decoding time zone names.
Review? Is init-on-demand for the Date formatters OK with threading?
| Assignee | ||
Comment 8•26 years ago
|
||
Comment 9•26 years ago
|
||
The proposed patches look good as far as I can tell. Could you commit them?
| Assignee | ||
Comment 10•26 years ago
|
||
Fixes checked in. Also removed unused isFinite function.
Status: NEW → RESOLVED
Closed: 26 years ago
Resolution: --- → FIXED
Comment 11•25 years ago
|
||
Testcases added to JS test suite for ECMA3 sections 15.9.5.3 to 15.9.5.7:
js/tests/ecma_3/Date/15.9.5.3.js - 15.9.5.7.js
Verified on Linux and WinNT -
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•