Added support for milliseconds in ISO 8601 timestamps [Closes #13]

This commit is contained in:
Ryan McGeary 2010-06-21 15:09:54 -04:00
parent 3109ef5d86
commit e8e3072d77
2 changed files with 7 additions and 0 deletions

View file

@ -84,6 +84,7 @@
},
parse: function(iso8601) {
var s = $.trim(iso8601);
s = s.replace(/\.\d\d\d/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
s = s.replace(/T/," ").replace(/Z/," UTC");
s = s.replace(/([\+-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400

View file

@ -70,6 +70,7 @@
<p>Date only (time element): <time class="timeago" datetime="2008-02-26">(you shouldn't see this)</time>.</p>
<p>Date only (friendly tooltip): <abbr id="testTooltip" class="timeago" title="2008-02-26">February 26th</abbr>.</p>
<p>Date only (default tooltip): <abbr id="defaultTooltip" class="timeago" title="2008-02-26"> </abbr>.</p>
<p>Timestsamp (with millis): <abbr class="timeago" title="1978-12-18T17:17:00.021Z">(you shouldn't see this)</abbr>.</p>
<h2>Errors</h2>
@ -89,6 +90,7 @@
<li><abbr id="testParsing5" class="todate" title="1978-12-19T02:17:00+09:00"></abbr> [from +09:00]</li>
<li><abbr id="testParsing6" class="todate" title="1978-12-19T02:17:00+0900"></abbr> [from +0900]</li>
<li><abbr id="testParsing7" class="todate" title="1978-12-18 17:17:00"></abbr> [from blank TZ]</li>
<li><abbr id="testParsing8" class="todate" title="1978-12-18 17:17:00.021Z"></abbr> [from Z with milliseonds]</li>
</ul>
<h2>Wording</h2>
@ -311,6 +313,10 @@
ok(($("#testParsing7").html().match(/Mon, 18 Dec 1978 \d\d:17:00 GMT/)), "Correctly parsed, assumed local time");
});
test("From Z with milliseconds", function () {
ok(($("#testParsing8").html().match(correctMatch)), "Correctly parsed");
});
module("Wording");
test("-120 min", function () {