Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Date arithmetic Date: Wed, 26 Nov 2014 01:40:30 +0100 Organization: solani.org Lines: 24 Message-ID: References: <0d947d29-c683-4417-b081-983f18bb11bf@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1416962424 4160 eJwNx8EBwEAEBMCWOJZNOY7ov4RkfgMLjU4PhGOxsVJPiiVVc6z+5+XxoTsOqQYp1svRQff9AP9CEHM= (26 Nov 2014 00:40:24 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 26 Nov 2014 00:40:24 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 X-User-ID: eJwFwQkRADAIAzBLfC2HnDGGfwlL4FTeDIKBxcrJCpHUtLaD4fjenjabaUc9Xek1Zr0Hd/sY3REj In-Reply-To: <0d947d29-c683-4417-b081-983f18bb11bf@googlegroups.com> Cancel-Lock: sha1:qyFQ582LkHmYxy7EEuPXL2jJ/no= X-NNTP-Posting-Host: eJwFwYEBwCAIA7CXRGgr54CO/09YAqfxKggGBlMtvIDXeXn7NHvXzi9M2XS4Q5bSKuOajfwBGv8QSw== Xref: csiph.com comp.lang.javascript:26213 RobG wrote: > Please don't suggest using the Date constructor to parse strings, > it's unreliable. For example, '2014-10-10' will be treated > differently in Chrome to most other browsers, Are you sure? It seems to me that only the external representation (toString()) is different, but the internal representation (valueOf()) is the same. > and IE 8 will return NaN. Indeed! > Also, where a pre-ES5 browser does successfully parse the > string, it may not highlight invalid dates (e.g. given 2014-02-29 it > may return a Date for 2014-03-01, whereas ES5 compliant browsers will > return NaN). It seems to me that ES 5.1 is not particularly clear with regard to this issue. -- Christoph M. Becker