Normative: Date.parse treats date-only no offset as UTC #138

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants
@bterlson
Member

bterlson commented Oct 28, 2015

This is a potential fix for #87. Previously, date-time forms without offsets were specified as local time and date-only forms were unspecified. This clarifies the web-reality semantics of interpreting date-only forms without offsets as UTC time.

Normative: Date.parse treats date-only no offset as UTC
Previously, date-time forms without offsets were specified as local time and date-only forms were unspecified. This clarifies the web-reality semantics of interpreting date-only forms without offsets as UTC time.
@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Oct 29, 2015

Member

LGTM

Member

rossberg commented Oct 29, 2015

LGTM

@mj1856

This comment has been minimized.

Show comment
Hide comment
@mj1856

mj1856 Oct 30, 2015

While this fixes the spec to match what browsers have implemented, I'd like to state for the record that I think it is wrong.

IMHO, the behavior should be consistent for both forms. Writing new Date("2015-01-01") should be identical to writing new Date("2015-01-01T00:00:00"), and that form can't be interpreted as UTC because otherwise there'd be no way to specify local time if you wanted to.

Of course, if midnight local time doesn't exist due to DST transition, such as 2016-10-16 in America/Sao_Paulo (Brazil), then 2016-10-16T00:00:00 should adjust forward to the start of the day, which would be 2016-10-16T01:00:00 in this case, which would apply to both date-only and date-time forms.

Hopefully this can be re-addressed in some future version.

mj1856 commented Oct 30, 2015

While this fixes the spec to match what browsers have implemented, I'd like to state for the record that I think it is wrong.

IMHO, the behavior should be consistent for both forms. Writing new Date("2015-01-01") should be identical to writing new Date("2015-01-01T00:00:00"), and that form can't be interpreted as UTC because otherwise there'd be no way to specify local time if you wanted to.

Of course, if midnight local time doesn't exist due to DST transition, such as 2016-10-16 in America/Sao_Paulo (Brazil), then 2016-10-16T00:00:00 should adjust forward to the start of the day, which would be 2016-10-16T01:00:00 in this case, which would apply to both date-only and date-time forms.

Hopefully this can be re-addressed in some future version.

@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Oct 30, 2015

Member

@mj1856, in an ideal world, I'd agree with you. But like so many problems with JavaScript, it turned out that this can't be fixed without breaking the web. So I doubt there's ever going to be a chance to rectify it.

Member

rossberg commented Oct 30, 2015

@mj1856, in an ideal world, I'd agree with you. But like so many problems with JavaScript, it turned out that this can't be fixed without breaking the web. So I doubt there's ever going to be a chance to rectify it.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 2, 2015

Member

FWIW, I also agree :) But I'm going to pull this in now!

Member

bterlson commented Nov 2, 2015

FWIW, I also agree :) But I'm going to pull this in now!

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 2, 2015

Member

Committed as 4f4a37a.

Member

bterlson commented Nov 2, 2015

Committed as 4f4a37a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment