我正在使用 DateJS 来解析用户输入的日期,并得到一些奇怪的结果.
I'm using DateJS to parse user-inputted dates, and getting some strange results.
Date.parse("15 Jan 2010")返回Fri Jan 15 00:00:00 EST 2010(右)
Date.parse("15-Apr-2010")返回Thu Apr 15 00:00:00 EDT 2010(右)
Date.parse("15 Apr 2010")返回Thu Apr 1 00:00:00 EDT 2010(错误)
据我所知,d MMM yyyy输入格式在除四月和八月外的每个月都可以正常工作;在这两种情况下,无论输入哪一天,它都会返回月份的第一天.这是一个错误,还是我缺少一个合乎逻辑的解释?
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?
推荐答案啊哈:看起来像下载" 链接比当前来源.这是承诺已修复此错误的:
Aha: Looks like the version in the "Download" link is a good bit older than the current source. Here's the commit that fixed this bug:
Dan Yoder使用timeContext模式修复了错误(如果包含日期) "april"或"august",分析器认为"a"是时间部分的开始 (如上午/下午). 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).EN-US脚本的最新版本在这里: code.google/p/datejs/source/browse/trunk/build/date-en-US.js 如果网站链接到该网站,而不是链接到几年未更新的zip文件,那就太好了.
The most recent version of the EN-US script is here: 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.
更多推荐
DateJS解析之谜
发布评论