Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Date arithmetic Date: Mon, 17 Nov 2014 01:11:40 +0100 Organization: PointedEars Software (PES) Lines: 27 Message-ID: <40469088.RWZSUOfdCW@PointedEars.de> References: <111120142237479787%timstreater@greenbee.net> <6814026.8sujcrue1K@PointedEars.de> <5592bc20-5fa3-4b2d-8534-1c81d62c31a5@googlegroups.com> <5371045.XxPr97Xf0d@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Trace: solani.org 1416183103 3092 eJwNyMERwCAMA7CVADt2Mg6Xlv1HgNNPAU21qRDjPF008e471LK8a1cCGkpU1g+laY3Z0VwX+VsPeQ== (17 Nov 2014 00:11:43 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Mon, 17 Nov 2014 00:11:43 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQEBACAIA7BK4M+VOIrSP4JbQK6aVIjR0UgsX4ruYfkuzHlfSSlsRyQbOzmmuY11smCHjzV4d/Y8+COfFHc= Cancel-Lock: sha1:ys9meoaVKRViTckmmYB3THlfrG0= X-NNTP-Posting-Host: eJwNyskBwDAIA7CZOOwm4wDF+4/Q6i0EjfMkwYSgCa2hXNVt1EFxPctymuHzp1GMcq+ffvt+MyQR6g== Xref: csiph.com comp.lang.javascript:26151 Thomas 'PointedEars' Lahn wrote: > Dr J R Stockton wrote: >> But we know that Swifty wants to process his _hand-entered_ dates. >> A quick test in current Firefox on an elderly PC shows that it executes a >> million of 'new Date()' in about 2.2 seconds. So there can be no >> perceptible advantage in doing anything other than 'new Date()' on each >> input, subtracting, dividing by 864e5, and rounding to integer, to get >> Swifty his date difference. > > You are missing the point and are preaching to the choir. It has already > been stated twice (at least) in this thread that for this use-case the > approach in jsx.date.getDayOfYear() is not the most efficient one, and > that the division approach is probably the best one. Although _not_ with new Date(), but with Date.UTC() after parsing the input string, because the former is susceptible both to non-standard parsing behavior and switches from/to DST while the latter is not. > After all, it was Christoph who suggested it first, in this thread at > least. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not Cc: me. / Bitte keine Kopien per E-Mail.