Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22372
| From | Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Date Conversion ? |
| Date | 2013-12-21 20:41 +0000 |
| Organization | Home |
| Message-ID | <RmsCCZj0zftSFwL8@invalid.uk.co.demon.merlyn.invalid> (permalink) |
| References | <bh9en6Foh76U1@mid.individual.net> <j5A+FiEA$JsSFwlR@invalid.uk.co.demon.merlyn.invalid> <bhckeoFed4lU1@mid.individual.net> <K5f01p0$U1sSFwA4@invalid.uk.co.demon.merlyn.invalid> <bhjavfFre0kU1@mid.individual.net> |
In comp.lang.javascript message <bhjavfFre0kU1@mid.individual.net>, Fri, 20 Dec 2013 09:52:57, Mel Smith <med_cutout_syntel@aol.com> posted: >Dr. J said: > >> Show us your code, and we can think about whether they are reliably >> solved. > >Hi Dr Stockton: > > Here's my latest iteration of my date checking function (which includes >JJ's parsedate() function and Thomas' Math function usage to find lows and >highs. 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. -- (c) John Stockton, nr London, UK. E-mail, see Home Page. 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
Date Conversion ? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-12-16 15:55 -0700
Re: Date Conversion ? Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2013-12-17 01:06 +0100
Re: Date Conversion ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-19 12:34 +0100
Re: Date Conversion ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-20 22:29 +0100
Re: Date Conversion ? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-23 10:00 -0200
Re: Date Conversion ? JJ <duh@nah.meh> - 2013-12-17 07:06 +0700
Re: Date Conversion ? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-17 00:35 +0000
Re: Date Conversion ? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-12-16 18:16 -0700
Re: Date Conversion ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-17 10:09 +0100
Re: Date Conversion ? Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-17 17:02 +0000
Re: Date Conversion ? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-18 19:14 +0000
Re: Date Conversion ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-19 15:42 +0100
Re: Date Conversion ? "Michael F. Stemper" <michael.stemper@gmail.com> - 2013-12-19 09:20 -0600
Re: Date Conversion ? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2013-12-20 10:04 +0100
Re: Date Conversion ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-17 15:12 +0100
Re: Date Conversion ? Joao Rodrigues <groups_jr-1@yahoo.com.br> - 2013-12-17 18:10 -0200
Re: Date Conversion ? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-17 21:42 +0100
Re: Date Conversion ? Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2013-12-18 13:36 +0100
Re: Date Conversion ? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-17 19:02 +0000
Re: Date Conversion ? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-12-17 20:51 -0700
Re: Date Conversion ? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-19 20:21 +0000
Re: Date Conversion ? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-12-20 09:52 -0700
Re: Date Conversion ? Dr J R Stockton <reply1300@merlyn.demon.co.uk.invalid> - 2013-12-21 20:41 +0000
Re: Date Conversion ? "Mel Smith" <med_cutout_syntel@aol.com> - 2013-12-22 09:52 -0700
csiph-web