Path: csiph.com!usenet.pasdenom.info!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: Wed, 19 Nov 2014 11:00:55 +0100 Organization: PointedEars Software (PES) Lines: 84 Message-ID: <1580490.WhVdJr593u@PointedEars.de> References: <111120142237479787%timstreater@greenbee.net> <6814026.8sujcrue1K@PointedEars.de> <5592bc20-5fa3-4b2d-8534-1c81d62c31a5@googlegroups.com> <5371045.XxPr97Xf0d@PointedEars.de> <40469088.RWZSUOfdCW@PointedEars.de> Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1416391258 31322 eJwFwYEBwDAEBMCVqs9jHCT2HyF3BgrHlUa1tb0DIKNujy480/q4VtlW/13J83FDbihkAX0uyhFq (19 Nov 2014 10:00:58 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 19 Nov 2014 10:00:58 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwYEBACAEBMCVFF6Ng8/+I3TnioUOg8N8fKp4bL+BKG++LkTtHAI0cPE0uH1C3SU7WDLSIUytG1fzA4CCFn4= Cancel-Lock: sha1:0Ahxb5nt0niCgy5mmYlvr3JunS0= X-NNTP-Posting-Host: eJwNwokRwDAIA7CV+GzKOASa/UdoT4JTORkEA/f3KK/eGsBea5xe2UjPPcEyYVusb9dYSlZ8Fc8Qog== Xref: csiph.com comp.lang.javascript:26158 Dr J R Stockton wrote: > Thomas 'PointedEars' Lahn posted: >>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. > > Perhaps you are not a churchgoer. Perhaps not. It does not matter. > In general, it seems to me that the boys and girls of a choir are likely > to be at least as much in need of being preached at as is the general > congregation. You are missing the point again. This English idiom refers to the fact that the choir usually stands behind the preacher, so he is addressing those who are not likely to be in need (in this case: not in need at all) of being preached at. > When attempting English clichés (always unwise for the non-English), one > should take great care to get them right; “Cliché” is not the right word here (“idiom” is). Otherwise you are right, and the same care should be taken with other languages, German in this case. > never assume that a foreign cliché remains good when translated literally. “Preaching to the choir” is _not_ a literal translation from German, which shows that you do not know as much German as you think. > You should have written "preaching to the converted". I *could* have written that, but it was not necessary to do so. The expression I have used is known in English-speaking countries. A Web search easily shows that. Then there are dictionaries in whose maintenance native- speakers participate, like I have heard or read the idiom years ago by a native speaker, and had no difficulty understanding what he/she meant. >> 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. > > The above rounding will take care of the seasonal clock changes, which > are not expected to exceed a couple of hours nett. > > Swifty already has his dates as yyyy-mm-dd. He can probably trust his > browser to understand that (and can easily check), > and he can append " GMT" to eliminate Summer Time worries. > With a RegExp, one can easily check for the format ####-##-## and change > the two '-' to '/' if desired and add the GMT bit. It is not logical to rely on probability, ambiguous or non-standard formats, and use of additional features, when you can have certainty with a standard approach and fewer requirements instead. > Note that such Date arithmetic can be unreliable near the International > Date Line, because of occurrences such as the omission of 2011-12-30 Fr1 > by Samoa (non-US) and Tokelau. Which is why UTC should be used instead. -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.