Are there any plans to introduce Date/Time literals?

Claude Pache claude.pache at gmail.com
Wed Oct 9 10:38:58 PDT 2013



> Le 9 oct. 2013 à 18:46, Oliver Hunt <oliver at apple.com> a écrit :
> 
> 
>> On Oct 9, 2013, at 1:35 AM, Claude Pache <claude.pache at gmail.com> wrote:
>> 
>> 
>>> 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.
> 
> Infinity and NaN a identifiers referencing properties on the global object — they’re not literals (nor is undefined).
> 
> These are all valid (but you shouldn’t do it):
> 
> function f(undefined, NaN, Infinity) {
> // dooooooommmmmm
> }
> 
> 
> function f() {
> var undefined = null /* fix that silly null vs. undefined shenanigans */, NaN = Math.sqrt(2) /* make sure nan is not rational */, Infinity = 10000000 /* this should be big enough */
> }
> 
> —Oliver

Yes, I know... Well, the next time, I will avoid to do an oversimplification in order to make my point, for there is always someone for splitting hairs. (Hopefully, RegExp literals remain. And I left as an exercise to the reader to understand what happens to -0 when transiting through JSON, and why... No, I won't discuss the answer.)

—Claude


More information about the es-discuss mailing list