Skip to content

Commit 1816b74

Browse files
committed
Merge pull request rmm5t#84 from arnaud-lb/pr0
fixed parsing of timestamps with decimal fraction of a second
2 parents 6f616b5 + 8083799 commit 1816b74

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

jquery.timeago.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
},
9292
parse: function(iso8601) {
9393
var s = $.trim(iso8601);
94-
s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
94+
s = s.replace(/\.\d+/,""); // remove milliseconds
9595
s = s.replace(/-/,"/").replace(/-/,"/");
9696
s = s.replace(/T/," ").replace(/Z/," UTC");
9797
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400

test/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ <h2>Parsing</h2>
9595
<li><abbr id="testParsing7" class="todate" title="1978-12-18 17:17:00"></abbr> [from blank TZ]</li>
9696
<li><abbr id="testParsing8" class="todate" title="1978-12-18 17:17:00.021Z"></abbr> [from Z with milliseonds]</li>
9797
<li><abbr id="testParsing9" class="todate" title="1978-12-18 17:17:00.021432Z"></abbr> [from Z with microseonds]</li>
98+
<li><abbr id="testParsing10" class="todate" title="1978-12-18 17:17:00.0Z"></abbr> [from Z with milliseonds]</li>
9899
</ul>
99100

100101
<h2>Wording</h2>
@@ -354,6 +355,10 @@ <h2>Settings</h2>
354355
ok(($("#testParsing9").html().match(correctMatch)), "Correctly parsed");
355356
});
356357

358+
test("From Z with microseconds", function () {
359+
ok(($("#testParsing10").html().match(correctMatch)), "Correctly parsed");
360+
});
361+
357362
module("Wording");
358363

359364
test("-120 min", function () {

0 commit comments

Comments
 (0)