Incorecttarget / protovis-js

Automatically exported from code.google.com/p/protovis-js
1 stars 0 forks source link

Date.parse doesn't work when there are no separators #38

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Date.parse('20091114', '%Y%m%d') fails to work as expected because the regex 
patterns used for 
every format specifier greedily match 1 or more characters/digits instead of 
limiting themselves, 
e.g. to ([0-9]{4}) or ([0-9]{2}).

Original issue reported on code.google.com by XboxFa...@gmail.com on 15 Nov 2009 at 5:57

GoogleCodeExporter commented 9 years ago
That is true. Of course, then you have a "Y10K" problem (and Y0K), because only 
in the current time is it valid to 
assume that the year takes exactly four digits. But regardless, we should 
compare our implementation to the 
standard strptime and make it consistent. Their documentation suggests assuming 
4-digit year for %Y and 2-
digit year for %y.

%m and %d should probably use [0-9]{1,2}, since it's valid for them to provide 
only a single digit if there is a 
word boundary.

Original comment by mbost...@gmail.com on 18 Jan 2010 at 7:42