Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #22356
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Date Conversion ? |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <bh9en6Foh76U1@mid.individual.net> <1l7578dngtzld$.19qzw1e0gy93t$.dlg@40tude.net> <l8o67q$tli$1@dont-email.me> |
| Date | 2013-12-17 10:09 +0100 |
| Message-ID | <XnsA299674D3AA55eejj99@194.109.133.133> (permalink) |
Denis McMahon wrote on 17 dec 2013 in comp.lang.javascript:
>> function parseDate(dateStr) {
>> //for "Mmm dd/yy" format, year 20nn only.
>> //converts to "Mmm dd yyyy" (good for FF, IE8, Chrome, Opera).
>> //returns NaN if dateStr is in invalid format.
>> var date=dateStr.replace(/([a-z]+ \d+)\/(\d+)/,"$1 20$2"); return (new
>> Date(date)).valueOf();
>> }
>
> To walk an array of numbers once to find the min and max values:
>
1 There is no need for conversion into a date object value,
[ and fearing a DST-change during the code's execution perhaps ;-) ]
Putting these numbers in the below array will do fine as well:
(year * 10000) + (month * 100) + (day * 1)
===================================
> var low, high, i;
> low = high = arr[0];
> for( i = 1; i < arr.length; i++ ) {
> if ( arr[i] < low ) low = arr[i];
> if ( arr[i] > high ) high = arr[i];
> }
2 You can just store the pointers,
supposedly those results are what you need in the html.
Try [not tested]:
var arr = [ -1, .... ];
var low = 0, high = 0, arrlen = arr.length, i;
for( i = 1; i < arrlen; i++ ) {
if ( arr[i] < arr[low] ) low = i;
if ( arr[i] > arr[high] ) high = i;
};
--
Evertjan.
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