Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

fixed parsing of timestamps with decimal fraction of a second #84

Merged
merged 1 commit into from

2 participants

@arnaud-lb

This fixes a bug in parsing timestamps with a fraction of second component.

The current code works only if the component has at least 3 digits; however it is not required that it has more than 1 digit ( per http://www.w3.org/TR/NOTE-datetime ).

@rmm5t rmm5t merged commit 1816b74 into rmm5t:master
@rmm5t
Owner

Thanks! I released v0.11.4 to incorporate this improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 6 additions and 1 deletion.
  1. +1 −1  jquery.timeago.js
  2. +5 −0 test/index.html
View
2  jquery.timeago.js
@@ -91,7 +91,7 @@
},
parse: function(iso8601) {
var s = $.trim(iso8601);
- s = s.replace(/\.\d\d\d+/,""); // remove milliseconds
+ s = s.replace(/\.\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
5 test/index.html
@@ -95,6 +95,7 @@ <h2 id="qunit-userAgent"></h2>
<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>
<li><abbr id="testParsing9" class="todate" title="1978-12-18 17:17:00.021432Z"></abbr> [from Z with microseonds]</li>
+ <li><abbr id="testParsing10" class="todate" title="1978-12-18 17:17:00.0Z"></abbr> [from Z with milliseonds]</li>
</ul>
<h2>Wording</h2>
@@ -354,6 +355,10 @@ <h2 id="qunit-userAgent"></h2>
ok(($("#testParsing9").html().match(correctMatch)), "Correctly parsed");
});
+ test("From Z with microseconds", function () {
+ ok(($("#testParsing10").html().match(correctMatch)), "Correctly parsed");
+ });
+
module("Wording");
test("-120 min", function () {
Something went wrong with that request. Please try again.