Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #16402
| From | Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: silly question on Date value evaluation or comparison |
| Date | 2012-10-04 19:36 +0100 |
| Organization | Home |
| Message-ID | <Gid5A8J8cdbQFwwl@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | (1 earlier) <k3tim5$hl1$1@speranza.aioe.org> <46cb7029-4d6f-421a-a2f2-7d3d18de660b@e14g2000yqm.googlegroups.com> <k3u1v3$kq2$1@dont-email.me> <+LUQ77IMbLZQFwll@invalid.uk.co.demon.merlyn.invalid> <dea8cd7c-f0b0-4fb9-ad55-22e749e17e31@googlegroups.com> |
In comp.lang.javascript message <dea8cd7c-f0b0-4fb9-ad55-22e749e17e31@go
oglegroups.com>, Wed, 3 Oct 2012 00:12:35, RobG <rgqld@iinet.net.au>
posted:
>On Friday, 28 September 2012 06:27:56 UTC+10, Dr J R Stockton wrote:
>[...]
>> NEVER use new Date() except for the measurement of intervals of time.
>
>Things like:
>
> var d = new Date(2012,9,3)
>
>are entirely consistent in every browser, I see no need to use any
>other method to create a date object.
That is not new Date(). And IMHO new Date("2012/10/03") is better than
new Date(2012,9,3), because it looks like what it means (and in my FF
15.0.1, WinXPsp3, it seems about 10% faster).
That format works in every browser that I've tried; no-one has reported
that, in any of my pages, it fails; and I've mentioned it often enough
here without being told of any failures either. Granted, the ECMA specs
do not *require* it to work. And it is good to show non-FFF dates to
the chronologically backward.
>> Use instead new Date(0), which gives consistent results and ought to be
>> faster.
>
>If the requirement is to create a date object for 1970-01-01T00:00:00Z,
>then you might be correct (even ignoring the obvious "faster than
>what?").
Simple grammar - new Date(0) is faster than new Date(), since the latter
must consult the operating system for the date and maybe convert it into
ms from 1970.0 UTC. At least, it is substantially faster in Windows,
and seems unlikely to be slower on any system.
> But that is likely an infrequent scenario.
It is infrequently needed; but, to judge from what I see, it is much
less infrequently used.
>Usually a date object is required to be set to a specific value other
>than the epoch, so what is the benefit to creating the object then
>setting its value (requireing at least one and maybe two further calls)
>over creating the object and setting its value in one call?
Agreed; but only the better sort of people realise that.
--
(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.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
silly question on Date value evaluation or comparison justaguy <lichunshen84@gmail.com> - 2012-09-25 17:21 -0700
Re: silly question on Date value evaluation or comparison Christoph Becker <cmbecker69@gmx.de> - 2012-09-26 02:36 +0200
Re: silly question on Date value evaluation or comparison justaguy <lichunshen84@gmail.com> - 2012-09-25 18:39 -0700
Re: silly question on Date value evaluation or comparison "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-09-26 07:57 +0300
Re: silly question on Date value evaluation or comparison Dr J R Stockton <reply1239@merlyn.demon.co.uk.invalid> - 2012-09-27 21:27 +0100
Re: silly question on Date value evaluation or comparison RobG <rgqld@iinet.net.au> - 2012-10-03 00:12 -0700
Re: silly question on Date value evaluation or comparison Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> - 2012-10-04 19:36 +0100
Re: silly question on Date value evaluation or comparison Scott Sauyet <scott.sauyet@gmail.com> - 2012-10-05 13:21 -0700
Re: silly question on Date value evaluation or comparison Dr J R Stockton <reply1240@merlyn.demon.co.uk.invalid> - 2012-10-06 19:06 +0100
Re: silly question on Date value evaluation or comparison "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-07 08:03 +0000
Re: silly question on Date value evaluation or comparison Patricia Shanahan <pats@acm.org> - 2012-10-07 09:48 +0100
Re: silly question on Date value evaluation or comparison "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2012-10-07 10:09 +0000
Re: silly question on Date value evaluation or comparison Gregor Kofler <usenet@gregorkofler.com> - 2012-09-26 09:11 +0200
csiph-web