Proposal-temporal: Accept Date.toString() output in from()?

Created on 17 Feb 2020  路  5Comments  路  Source: tc39/proposal-temporal

From @jasonwilliams in https://github.com/tc39/proposal-temporal/pull/366:

Do we want to give more detail here on what the string should/should not be?
Is it just an ISO 8601 string? the output from Date() also?

See the format described in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toString. (Although note it was implementation-dependent before ES2018.)

has-consensus

Most helpful comment

I would not require acceptance of Date.prototype.toString output, which is nonstandard outside ECMAScript and includes implementation-defined contents after the UTC offset, and is not even necessarily accepted by legacy Date.parse (which violates a "should" requirement in the spec, but is nonetheless web reality). The interchange-friendly format is available via Date.prototype.toISOString, and that should be enough.

All 5 comments

@gibson042 has done a lot of work in this area, and is the one who wrote the new spec for Date.prototype.toString. He attempted to do a similar thing with Date.parse, but that failed at plenary because all the browsers had different behavior and the implementations didn't want to change.

I would not require acceptance of Date.prototype.toString output, which is nonstandard outside ECMAScript and includes implementation-defined contents after the UTC offset, and is not even necessarily accepted by legacy Date.parse (which violates a "should" requirement in the spec, but is nonetheless web reality). The interchange-friendly format is available via Date.prototype.toISOString, and that should be enough.

Agreed @gibson042 we should have a cookbook example showing how to do this, as i imagine a common question will be "how to switch between the old and the new".

We have the cookbook example now, so closing this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

felixfbecker picture felixfbecker  路  6Comments

littledan picture littledan  路  4Comments

sffc picture sffc  路  5Comments

justingrant picture justingrant  路  4Comments

romulocintra picture romulocintra  路  6Comments