Permalink
Browse files

Merge remote-tracking branch 'Akral/master' into natural_rounding

* Akral/master:
  Natural rounding for days, months and years.
  • Loading branch information...
2 parents 6d16a03 + 5353c18 commit a56c87db014be9ac91026cf4180b66dc6d735caa @rmm5t committed Mar 7, 2012
Showing with 23 additions and 10 deletions.
  1. +6 −6 jquery.timeago.js
  2. +17 −4 test/index.html
View
@@ -77,12 +77,12 @@
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && substitute($l.hour, 1) ||
hours < 24 && substitute($l.hours, Math.round(hours)) ||
- hours < 48 && substitute($l.day, 1) ||
- days < 30 && substitute($l.days, Math.floor(days)) ||
- days < 60 && substitute($l.month, 1) ||
- days < 365 && substitute($l.months, Math.floor(days / 30)) ||
- years < 2 && substitute($l.year, 1) ||
- substitute($l.years, Math.floor(years));
+ hours < 42 && substitute($l.day, 1) ||
+ days < 30 && substitute($l.days, Math.round(days)) ||
+ days < 45 && substitute($l.month, 1) ||
+ days < 365 && substitute($l.months, Math.round(days / 30)) ||
+ years < 1.5 && substitute($l.year, 1) ||
+ substitute($l.years, Math.round(years));
return $.trim([prefix, words, suffix].join($l.wordSeparator));
},
View
@@ -112,12 +112,15 @@ <h2 id="qunit-userAgent"></h2>
<li><abbr id="testWording13" class="towords" title="7200"></abbr> [120 min]</li>
<li><abbr id="testWording14" class="towords" title="82800"></abbr> [1380 min]</li>
<li><abbr id="testWording15" class="towords" title="90000"></abbr> [25 hours]</li>
- <li><abbr id="testWording16" class="towords" title="172800"></abbr> [48 hours]</li>
+ <li><abbr id="testWording16a" class="towords" title="147600"></abbr> [41 hours]</li>
+ <li><abbr id="testWording16b" class="towords" title="151200"></abbr> [42 hours]</li>
+ <li><abbr id="testWording16c" class="towords" title="172800"></abbr> [48 hours]</li>
<li><abbr id="testWording17" class="towords" title="2505600"></abbr> [696 hours]</li>
<li><abbr id="testWording18" class="towords" title="2592000"></abbr> [30 days]</li>
<li><abbr id="testWording19" class="towords" title="16416000"></abbr> [190 days]</li>
<li><abbr id="testWording20" class="towords" title="31622400"></abbr> [366 days]</li>
- <li><abbr id="testWording21" class="towords" title="94608000"></abbr> [1095 days]</li>
+ <li><abbr id="testWording21" class="towords" title="62640000"></abbr> [725 days]</li>
+ <li><abbr id="testWording22" class="towords" title="94608000"></abbr> [1095 days]</li>
</ul>
<h2>Settings</h2>
@@ -402,8 +405,14 @@ <h2 id="qunit-userAgent"></h2>
ok(($("#testWording15").html() === "a day ago"), "Correctly parsed");
});
+ test("41 hour", function () {
+ ok(($("#testWording16a").html() === "a day ago"), "Correctly parsed");
+ });
+ test("42 hours", function () {
+ ok(($("#testWording16b").html() === "2 days ago"), "Correctly parsed");
+ });
test("48 hours", function () {
- ok(($("#testWording16").html() === "2 days ago"), "Correctly parsed");
+ ok(($("#testWording16c").html() === "2 days ago"), "Correctly parsed");
});
test("696 hours", function () {
@@ -422,8 +431,12 @@ <h2 id="qunit-userAgent"></h2>
ok(($("#testWording20").html() === "about a year ago"), "Correctly parsed");
});
+ test("725 days", function () {
+ ok(($("#testWording21").html() === "2 years ago"), "Correctly parsed");
+ });
+
test("1095 days", function () {
- ok(($("#testWording21").html() === "3 years ago"), "Correctly parsed");
+ ok(($("#testWording22").html() === "3 years ago"), "Correctly parsed");
});
module("Settings");

0 comments on commit a56c87d

Please sign in to comment.