From e8e3072d77c2ea6a315075dcde6529588e358a89 Mon Sep 17 00:00:00 2001 From: Ryan McGeary Date: Mon, 21 Jun 2010 15:09:54 -0400 Subject: [PATCH] Added support for milliseconds in ISO 8601 timestamps [Closes #13] --- jquery.timeago.js | 1 + test/index.html | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/jquery.timeago.js b/jquery.timeago.js index f0e6b55..febe400 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -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 diff --git a/test/index.html b/test/index.html index 541edf2..67dc3ad 100644 --- a/test/index.html +++ b/test/index.html @@ -70,6 +70,7 @@

Date only (time element): .

Date only (friendly tooltip): February 26th.

Date only (default tooltip): .

+

Timestsamp (with millis): (you shouldn't see this).

Errors

@@ -89,6 +90,7 @@
  • [from +09:00]
  • [from +0900]
  • [from blank TZ]
  • +
  • [from Z with milliseonds]
  • Wording

    @@ -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 () {