datejs / Datejs

A JavaScript Date and Time Library
Other
1.89k stars 483 forks source link

Unable to parseExact a string in a certain format #55

Open geoffreymcgill opened 9 years ago

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

I commented here - http://code.google.com/p/datejs/wiki/FormatSpecifiers - but 
realized that 
may not have been the right place.

I'm trying to parseExact a date string like "yyyy-MM-ddTHH:mm:ss.000-05:00" but 
the latter part 
(-05:00) breaks if it's a different time zone (-06:00) is present. I've tried 
using "P" (noted above) but 
no joy. I'm using trunk. I can't change the format... google calendar RSS. :)

I've also tried using just "c", but the presence of milliseconds in the string 
breaks it.

Anything I can try?

Original issue reported on code.google.com by redeemer...@gmail.com on 24 May 2008 at 3:30

Copied from original issue: datejs/DateJS#41

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

Yep, this is a problem. The millisecond value in the iso 8601 format will cause
problems in the regex parsing. Without the millisecond value everything should 
be
fine. I have not had a chance to investigate a fix, but it will almost certainly
involve an addition or modification to the regex that attempts to parse the
millisecond part. 

Original comment by geoff on 25 May 2008 at 3:28

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

This issue has gained higher visibility after Blogger changed the output format 
of
their Atom feeds. The "updated" field now shows dates like:

2003-12-13T18:30:02.25+01:00

Unfortunately datejs is unable to parse this.
Is there a simple workaround while this bug is fixed?

Original comment by sergio.n...@gmail.com on 25 May 2008 at 4:01

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

Just a quick note to add that these are valid RFC 3339 dates:

http://www.ietf.org/rfc/rfc3339.txt

Original comment by sergio.n...@gmail.com on 25 May 2008 at 4:07

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

FYI, for my immediate purposes, I just grepped the milliseconds out of the 
string.

Original comment by redeemer...@gmail.com on 27 May 2008 at 4:44

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

Hi, here is patch that fixes the ISO 8601 milliseconds format problem.
Adds a new "iii" format, matches 3 digits with optional start dot
Adds a new format to use with parse() that parses ISO 8601 with milliseconds

Original comment by mattias....@gmail.com on 5 Feb 2010 at 4:38

Attachments:

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

New patch, use "ss.s" as format instead which is much better and according to 
the 
format specification

Original comment by mattias....@gmail.com on 5 Feb 2010 at 7:43

Attachments:

geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

[deleted comment]
geoffreymcgill commented 9 years ago

From @GoogleCodeExporter on April 18, 2015 5:50

patched in my current fork: https://github.com/abritinthebay/datejs/

Original comment by darkcr...@gmail.com on 9 Sep 2013 at 7:57