Are there any plans to introduce Date/Time literals?

Claude Pache claude.pache at gmail.com
Wed Oct 9 01:35:05 PDT 2013


Le 8 oct. 2013 à 23:43, Andrew Fedoniouk <news at terrainformatica.com> a écrit :

> Quite often Date values are used in data exchanges in form of JS
> literals or JSON.
> 
> It would be beneficial if JS (and JSON as derivative) will have an
> ability to represent dates literally  . For example:

Even if there had been a dedicated syntax to write literal dates in JS, it doesn't mean that JSON would have allowed such a representation.
For instance, the following entities have literal representation in JS, but do not exist in JSON, by the will of its designer: Infinity, NaN, and regular expressions.

Conversely, you can define a superset of JSON that doesn't parse as a JS expression. 
(In fact, `JSON.parse` does already produce different results from `eval` for edge cases.)

Unrelated to JSON, note that there is already a convenient way to write down a literal date in JS, namely: `new Date("2014-11-05T13:15:30Z")`.

—Claude



More information about the es-discuss mailing list