admin管理员组文章数量:1023885
I'm using DateJS to parse user-inputted dates, and getting some strange results.
Date.parse("15 Jan 2010")
returnsFri Jan 15 00:00:00 EST 2010
(right)Date.parse("15-Apr-2010")
returnsThu Apr 15 00:00:00 EDT 2010
(right)Date.parse("15 Apr 2010")
returnsThu Apr 1 00:00:00 EDT 2010
(wrong)
As far as I can tell, the d MMM yyyy
input format works fine for every month except April and August; in those two cases, it returns the first of the month no matter what day is entered. Is this a bug, or is there a logical explanation I'm missing?
I'm using DateJS to parse user-inputted dates, and getting some strange results.
Date.parse("15 Jan 2010")
returnsFri Jan 15 00:00:00 EST 2010
(right)Date.parse("15-Apr-2010")
returnsThu Apr 15 00:00:00 EDT 2010
(right)Date.parse("15 Apr 2010")
returnsThu Apr 1 00:00:00 EDT 2010
(wrong)
As far as I can tell, the d MMM yyyy
input format works fine for every month except April and August; in those two cases, it returns the first of the month no matter what day is entered. Is this a bug, or is there a logical explanation I'm missing?
- 1 well when I go to the DateJS home page and type in "15 Apr 2010", it sure seems to work ... – Pointy Commented Mar 12, 2010 at 17:09
1 Answer
Reset to default 9Aha: Looks like the version in the "Download" link is a good bit older than the current source. Here's the mit that fixed this bug:
Dan Yoder fixed bug with timeContext pattern where if a date included "april" or "august", the parser thought the 'a' was the beginning of a time part (as in am/pm).
The most recent version of the EN-US script is here: http://code.google./p/datejs/source/browse/trunk/build/date-en-US.js It would be nice if the website linked to this instead of to a zip file that hasn't been updated for a couple of years.
I'm using DateJS to parse user-inputted dates, and getting some strange results.
Date.parse("15 Jan 2010")
returnsFri Jan 15 00:00:00 EST 2010
(right)Date.parse("15-Apr-2010")
returnsThu Apr 15 00:00:00 EDT 2010
(right)Date.parse("15 Apr 2010")
returnsThu Apr 1 00:00:00 EDT 2010
(wrong)
As far as I can tell, the d MMM yyyy
input format works fine for every month except April and August; in those two cases, it returns the first of the month no matter what day is entered. Is this a bug, or is there a logical explanation I'm missing?
I'm using DateJS to parse user-inputted dates, and getting some strange results.
Date.parse("15 Jan 2010")
returnsFri Jan 15 00:00:00 EST 2010
(right)Date.parse("15-Apr-2010")
returnsThu Apr 15 00:00:00 EDT 2010
(right)Date.parse("15 Apr 2010")
returnsThu Apr 1 00:00:00 EDT 2010
(wrong)
As far as I can tell, the d MMM yyyy
input format works fine for every month except April and August; in those two cases, it returns the first of the month no matter what day is entered. Is this a bug, or is there a logical explanation I'm missing?
- 1 well when I go to the DateJS home page and type in "15 Apr 2010", it sure seems to work ... – Pointy Commented Mar 12, 2010 at 17:09
1 Answer
Reset to default 9Aha: Looks like the version in the "Download" link is a good bit older than the current source. Here's the mit that fixed this bug:
Dan Yoder fixed bug with timeContext pattern where if a date included "april" or "august", the parser thought the 'a' was the beginning of a time part (as in am/pm).
The most recent version of the EN-US script is here: http://code.google./p/datejs/source/browse/trunk/build/date-en-US.js It would be nice if the website linked to this instead of to a zip file that hasn't been updated for a couple of years.
本文标签: javascriptDateJS parsing mysteryStack Overflow
版权声明:本文标题:javascript - DateJS parsing mystery - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745525273a2154495.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论