New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standardize Date.prototype.toString further? #845

Open
littledan opened this Issue Mar 10, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@littledan
Member

littledan commented Mar 10, 2017

Across multiple JS implementations, it seems that Date.prototype.toString writes the timezone (in parens) in a long, locale-dependent form on Windows, but in a short form (2-4 letters) from the tz database on Unix-based OSes. More details in the V8 bug tracker.

The spec is really light on details for Date.prototype.toString:

Return an implementation-dependent String value that represents tv as a date and time in the current time zone using a convenient, human-readable form.

Does anyone have a good memory of why this is the definition? Looks like it goes all the way back to ES1.

Fortunately, it seems that, at this point, implementations have converged on something that's almost always the same, with the exception of the timezone string.

For the timezone string, would it be a good idea to pick one of the two alternatives and standardize it across all platforms? Does anyone have evidence one way or the other whether either of the two is likely to be more web-compatible, or whether we need to preserve the variation?

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Mar 12, 2017

Member

Crazy idea: what if we standardized on omitting the parenthized "readable" timezones, leaving just the preceding GMT+-... This would be analogous to IS08601. As @anba pointed out Firefox has had a bug where it omitted many of these timezones already, so maybe the web would be able to handle the loss.

Member

littledan commented Mar 12, 2017

Crazy idea: what if we standardized on omitting the parenthized "readable" timezones, leaving just the preceding GMT+-... This would be analogous to IS08601. As @anba pointed out Firefox has had a bug where it omitted many of these timezones already, so maybe the web would be able to handle the loss.

littledan added a commit that referenced this issue Mar 17, 2017

Normative: Specify Date string conversion functions
Implementations seem to agree on semantics here for the most
part, modulo timezone strings, which are left implementation-defined.

Addresses part of #845

littledan added a commit to littledan/ecma262 that referenced this issue Mar 22, 2017

Normative: Specify Date string conversion functions
Implementations seem to agree on semantics here for the most
part, modulo timezone strings, which are left implementation-defined.

Addresses part of tc39#845
@jungshik

This comment has been minimized.

Show comment
Hide comment
@jungshik

jungshik Apr 28, 2017

Contributor

Crazy idea: what if we standardized on omitting the parenthized "readable" timezones, leaving just the preceding GMT+-... This would be analogous to IS08601. As @anba pointed out Firefox has had a bug where it omitted many of these timezones already, so maybe the web would be able to handle the loss.

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

Contributor

jungshik commented Apr 28, 2017

Crazy idea: what if we standardized on omitting the parenthized "readable" timezones, leaving just the preceding GMT+-... This would be analogous to IS08601. As @anba pointed out Firefox has had a bug where it omitted many of these timezones already, so maybe the web would be able to handle the loss.

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

@jungshik

This comment has been minimized.

Show comment
Hide comment
@jungshik

jungshik Apr 28, 2017

Contributor

Another alternative is

UTC+-.... (Olsaon Timezone ID with "_" replaced for a space for the readability)

For instance, UTC-0400 (America/New York)

Modern platforms would have Olson timezone ids handy so that implementation wouldn't be hard.

Contributor

jungshik commented Apr 28, 2017

Another alternative is

UTC+-.... (Olsaon Timezone ID with "_" replaced for a space for the readability)

For instance, UTC-0400 (America/New York)

Modern platforms would have Olson timezone ids handy so that implementation wouldn't be hard.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Apr 30, 2017

Member

@jungshik

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

Well, you'd think so, but it seems like all browsers are shipping printing it as GMT, so I'm not sure if it would be web-compatible to change that.

For instance, UTC-0400 (America/New York)

I like this idea. It might be more likely to work on the web than just omitting that text because it preserves some parenthesized text with something that's vaguely human-readable inside. I don't think we should be adding tons of features to Date, but this seems relatively appropriate, intuitively.

Any other thoughts? cc @maggiepint

Member

littledan commented Apr 30, 2017

@jungshik

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

Well, you'd think so, but it seems like all browsers are shipping printing it as GMT, so I'm not sure if it would be web-compatible to change that.

For instance, UTC-0400 (America/New York)

I like this idea. It might be more likely to work on the web than just omitting that text because it preserves some parenthesized text with something that's vaguely human-readable inside. I don't think we should be adding tons of features to Date, but this seems relatively appropriate, intuitively.

Any other thoughts? cc @maggiepint

@jungshik

This comment has been minimized.

Show comment
Hide comment
@jungshik

jungshik May 4, 2017

Contributor

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

Well, you'd think so, but it seems like all browsers are shipping printing it as GMT, so I'm not sure if it would be web-compatible to change that.

It looks like I have to live with GMT forever. I really hate to see GMT linger on 40+ years after its 'dethroning'. :-)

Contributor

jungshik commented May 4, 2017

Might work, but shouldn't we standardize to 'UTC...' instead of 'GMT...'?

Well, you'd think so, but it seems like all browsers are shipping printing it as GMT, so I'm not sure if it would be web-compatible to change that.

It looks like I have to live with GMT forever. I really hate to see GMT linger on 40+ years after its 'dethroning'. :-)

bterlson added a commit that referenced this issue May 30, 2017

Normative: Specify Date string conversion functions (#848)
* Normative: Specify Date string conversion functions

Implementations seem to agree on semantics here for the most
part, modulo timezone strings, which are left implementation-defined.

Addresses part of #845

* Move 'and'

* Delete extraneous '_result_'

* Fix GMT+-HHMM with @claudepache's text

* toUTCString has a comma after the day of the week

Also fix up the text of DateString().

* Date and time components are padded to the left by 0

This actually gets into an area of apparent disagreement between
implementations. For years less than 1000, JSC and SpiderMonkey
implement the specification here, whereas V8 pads to four digits
with spaces, and ChakraCore does not pad the number.

* toUTCString swaps month and day
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment