DateJS解析之谜

编程入门 行业动态 更新时间:2024-10-27 18:26:27
本文介绍了DateJS解析之谜的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用 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解析之谜

    本文发布于:2023-11-08 18:49:55,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1570143.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:之谜   DateJS

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!