"Dr John Stockton" <jrs@merlyn.demon.co.uk> wrote in message
news:bww6QyB83JFDFwvP@merlyn.demon.co.uk...[color=blue]
> JRS: In article <devios01t7t@news1.newsguy.com>, dated Mon, 29 Aug 2005
> 14:05:21, seen in news:comp.lang.javascript, Jim Davis
> <newsmonkey@vboston.com> posted :[color=green]
>>Before I reinvent the wheel I thought I'd ask: anybody got a code snippet
>>that will convert the common ISO8601 date formats to a JS date?
>>
>>By "common" I mean at the least ones described in this W3C note:
>>
>>
http://www.w3.org/TR/NOTE-datetime[/color]
>
> URLs should be encased in <...> or <URL:...> for optimum reader
> satisfaction. However, you should remember that those who read News
> off-line would prefer to see the information in the article itself.[/color]
Point well taken.
[color=blue][color=green]
>>For my requirements the code would be need to be open sourceable under the
>>BSD license.[/color]
>
> Bovine Spongiform Disencephaly?[/color]
Well... in this case let's say that if you don't know then it doesn't matter
to you.
[color=blue][color=green]
>>If not then my plan is to do a RegEx for each of the formats and attempt
>>to
>>match from the most complex to the least. (I'm not searching through
>>arbitrary text but rather examining a single value that SHOULD be a date
>>in
>>one of those formats) Sound like a plan?[/color]
>
> The structure of the formats is, as I recall, rigid yyyy-mm-dd or yyyy-
> Www-d or yyyy-ddd except that parts may be omitted. In that case, you
> may only need the RegExps, as long as you are prepared to accept empty
> parts. But note that ISO 8601:2000 allows some representations to be
> used only by agreement.[/color]
I was able to address the problem with a coupla of RegExp's in the end. I
was hoping to be able to adopt something off the shelf, but finding nothing
went ahead and did it. Once it's been cleaned up I plan to release it to
community.
The purpose is not to represent a full 8601 parser (I'll leave that to much
bigger brains) - only to parse those (6) formats specified by the WC3 note.
[color=blue]
> Processing data in various ways until some form which might be correct
> is tried is a very American thing to do, and usually leads to error in
> the end. In a non-ISO context, success with Christmas Day does not
> justify presumption of success with Guy Fawkes' Day.[/color]
I really haven't the faintest idea what you're talking about here... ;^)
This is not a "fishing expedition" but rather a situation where arbitrary
dates may be sent. The six formats required cover a range of progressive
specificity and so the parser should understand them all.
[color=blue]
> Please read the newsgroup FAQ before asking questions. See below.[/color]
The FAQ doesn't seem to inform this question... is there something specific
in it you're suggesting I missed? Or do you just say this a lot? ;^)
Jim Davis