Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #12971 > unrolled thread

+new Date("2012-03-21") and +new Date("2012/03/21") can differ by up to about 432e5

Started byDr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid>
First post2012-03-21 19:38 +0000
Last post2012-03-24 00:09 +0000
Articles 4 — 2 participants

Back to article view | Back to comp.lang.javascript


Contents

  +new Date("2012-03-21") and +new Date("2012/03/21")  can differ by up to about 432e5 Dr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid> - 2012-03-21 19:38 +0000
    Re: +new Date("2012-03-21") and +new Date("2012/03/21")  can differ by up to about 432e5 "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-22 16:21 +0000
      Re: +new Date("2012-03-21") and +new Date("2012/03/21")  can differ by up to about 432e5 Dr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid> - 2012-03-23 22:25 +0000
        Re: +new Date("2012-03-21") and +new Date("2012/03/21")  can differ by up to about 432e5 "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-03-24 00:09 +0000

#12971 — +new Date("2012-03-21") and +new Date("2012/03/21") can differ by up to about 432e5

FromDr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid>
Date2012-03-21 19:38 +0000
Subject+new Date("2012-03-21") and +new Date("2012/03/21") can differ by up to about 432e5
Message-ID<ER$+NdFv4iaPFw2u@invalid.uk.co.demon.merlyn.invalid>
For those who had not noticed : it appears that the results from each
line in

        +new Date("2012/01/21")         &       +new Date("2012-01-21")
and
        +new Date("2012/07/21")         &       +new Date("2012-07-21")

can differ by up to about 432e5, dependent on location.

The former is almost required to, and traditionally does, give a
midnight of local time.

The latter seems to give (NaN or) a midnight of GMT.

Could that be checked in other places, particularly away from winter
time = GMT ?

I imagine that in the route from ISO 8601 to JSON to JavaScript, a major
stupidity has occurred and needs to be stamped out.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

[toc] | [next] | [standalone]


#12983

From"Evertjan." <exjxw.hannivoort@interxnl.net>
Date2012-03-22 16:21 +0000
Message-ID<XnsA01EB082E8886eejj99@194.109.133.133>
In reply to#12971
Dr J R Stockton wrote on 21 mrt 2012 in comp.lang.javascript:

> For those who had not noticed : it appears that the results from each
> line in
> 
>         +new Date("2012/01/21")         &       +new Date("2012-01-21")
> and
>         +new Date("2012/07/21")         &       +new Date("2012-07-21")
> 
> can differ by up to about 432e5, dependent on location.

About? The below shows exactly one or two hours difference overhere [CET].

<script type='text/javascript'>

// cet = gmt+1
a = new Date("2012/01/21");
b = new Date("2012-01-21");

//alert(a);
//alert(b);
alert((b-a)/(60*60*1000) + ' hour'); // 1 hour

a = new Date("2012/07/21");
b = new Date("2012-07-21");

// cet = gmt+2
//alert(a);
//alert(b);
alert((b-a)/(60*60*1000) + ' hours'); // 2 hours

</script>



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#13021

FromDr J R Stockton <reply1212@merlyn.demon.co.uk.not.invalid>
Date2012-03-23 22:25 +0000
Message-ID<2MYi6wH0hPbPFwIa@invalid.uk.co.demon.merlyn.invalid>
In reply to#12983
In comp.lang.javascript message <XnsA01EB082E8886eejj99@194.109.133.133>
, Thu, 22 Mar 2012 16:21:07, Evertjan. <exjxw.hannivoort@interxnl.net>
posted:

>Dr J R Stockton wrote on 21 mrt 2012 in comp.lang.javascript:
>
>> For those who had not noticed : it appears that the results from each
>> line in
>>
>>         +new Date("2012/01/21")         &       +new Date("2012-01-21")
>> and
>>         +new Date("2012/07/21")         &       +new Date("2012-07-21")
>>
>> can differ by up to about 432e5, dependent on location.
>
>About? The below shows exactly one or two hours difference overhere [CET].

You're quite near the Greenwich Meridian.  Australians and Hawaiians are
about 10 hours away, Kiribatians 14 hours I think.

<FAQENTRY> new Date("YYYY/MM/DD") is not specified to work, but always
gives that date, local 0 hours. But new Date("YYYY-MM-DD") is specified
to work, but, although the string is a common ISO 8601 representation of
0h local on that date, that expression gives 0h GMT of that date.

Someone has been Really Stupid there, and it will lead to incessant
error.


Over here the general view is that the Dutch all use excellent English,
though perhaps with a slight accent (and peculiar spelling).  Which is
more than can be said for anyone raised at more than 30 degrees West
longitude.  In that region, being north of the 49th parallel helps less
than it used to.

-- 
 (c) John Stockton, nr London, UK.    ?@merlyn.demon.co.uk     Turnpike v6.05.
 Website  <http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
 PAS EXE etc. : <http://www.merlyn.demon.co.uk/programs/> - see in 00index.htm
 Dates - miscdate.htm estrdate.htm js-dates.htm pas-time.htm critdate.htm etc.

[toc] | [prev] | [next] | [standalone]


#13023

From"Evertjan." <exjxw.hannivoort@interxnl.net>
Date2012-03-24 00:09 +0000
Message-ID<XnsA020BB9C29BBeejj99@194.109.133.133>
In reply to#13021
Dr J R Stockton wrote on 23 mrt 2012 in comp.lang.javascript:

> Over here the general view is that the Dutch all use excellent English,
> though perhaps with a slight accent (and peculiar spelling).  Which is
> more than can be said for anyone raised at more than 30 degrees West
> longitude.  In that region, being north of the 49th parallel helps less
> than it used to.

That being said, a litle south of the said parallel and over 123 degrees 
west, spelling isn't that bad in my experience.

> Someone has been Really Stupid there, 
> and it will lead to incessant error.

However even south of Ladysmith BC, new Date is felt as a sexual 
opportunity, not as error-prone Javascript.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web