Skip to content

Conversation

@jugglinmike
Copy link

The behavior of the Date constructor is changing in ECMAScript 6: Date strings that do not specify a time zone will be interpreted in the local time (and not as GMT). This will cause Ampersand State's built-in date data type to behave inconsistently across platforms.

This patch ensures consistency by explicitly interpreting Date strings without a time zone in the local system time in ECMAScript 5 environments. This should be considered a breaking change, which I recognize is a point against it. It would certainly be possible to avoid the break by instead patching the date data type to maintain its current behavior in ES6 environments, but I think that would be a nearsighted solution for two reasons:

  1. Developers will quickly learn the new Date constructor behavior and come to expect it from abstractions that use it.
  2. The new behavior is actually more useful because it's otherwise impossible for the server to instruct the client to interpret a date according to its local time zone.

Commit message:

In ECMAScript 6, the Date constructor will interpret ISO 8601 Date strings in
the local system time zone when no time zone is specified. This is in
contrast to the behavior in ECMAScript 5.1, where UTC is assumed.

Mimic the future behavior so that clients behave consistently across
platforms.

In ECMAScript 6, the Date constructor will interpret ISO 8601 Date
strings in the local system time zone when no time zone is specified.
This is in contrast to the behavior in ECMAScript 5.1, where UTC is
assumed.

Mimic the future behavior so that clients behave consistently across
platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants