Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: "Mel Smith" Newsgroups: comp.lang.javascript Subject: Re: Date Conversion ? Date: Sun, 22 Dec 2013 09:52:40 -0700 Lines: 46 Message-ID: References: X-Trace: individual.net U19YEiY+EE8Q5udAh9kIzQDgnMujD8YeYYmducQNGn3/5vKrDi Cancel-Lock: sha1:zQaLNvDTlN1NkVkFhCI+N5B9CpE= X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Xref: csiph.com comp.lang.javascript:22373 Dr Stockton said: > JJ is inept. That function accepts dates before and after the end of the > month named. Date checking is in the newsgroup FAQ, and on my Web site. > Form numbers for Y M' D, use nD = new Date(Date.UTC(Y, M', D)), and > check whether nD.getUTCMonth() agrees with M'. IIRC, that method fails > for the end of February in Year Zero. That's written from memory but is > at least about right - it assumes the date field is assuredly of no more > than two digits. > > The original article did not mention date checking; if it is machine- > generated or already checked, there should be no need to check it again. > > Your code uses local date routines. Those, in temperate countries, are > substantially slower than UTC routines, since the date offset from GMT > must be found and used. > > The Date Object is not needed, and its creation wastes time. You can > extract the Mmm dd yy fields, convert Mmm to a number mm as already > described, and form (yy*100+mm)*100+dd which is easily seen to be an > integer rising by at least 1 at each midnight. But, if you do check > with a Date Object, use its value for comparisons. > > I do not know whether it will be quicker to load those into an array and > then use Math.(min|max).apply, or to just watch for increased or > decreased values. If speed matters to you, you should test that and > report the result to enlighten the rest of us. > > Your code is not executable as posted, for at least two reasons. Never > allow your posting agent to line-wrap code. > > I'm still not clear as to whether you want to find the values or the > positions or both for the earliest and latest dates. > Because of Christmas coming fast at us and because of guests arriving at my winter home in Arizona, I must wait a week or so before I delve deeper into your critique. Bur, thank you for your analysis, and ... Merry Christmas to you and all the folks here on this ng ! -Mel Smith