Permalink
Browse files

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

  • Loading branch information...
1 parent 3109ef5 commit e8e3072d77c2ea6a315075dcde6529588e358a89 @rmm5t committed Jun 21, 2010
Showing with 7 additions and 0 deletions.
  1. +1 −0 jquery.timeago.js
  2. +6 −0 test/index.html
View
@@ -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
@@ -70,6 +70,7 @@ <h2 id="userAgent"></h2>
<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 @@ <h2 id="userAgent"></h2>
<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 @@ <h2 id="userAgent"></h2>
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 () {

0 comments on commit e8e3072

Please sign in to comment.