mirror of
https://github.com/scratchfoundation/jquery-timeago.git
synced 2025-02-17 00:20:32 -05:00
Natural rounding for days, months and years.
This commit is contained in:
parent
389c1af715
commit
5353c1849d
2 changed files with 23 additions and 10 deletions
|
@ -76,12 +76,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(" "));
|
||||
},
|
||||
|
|
|
@ -112,12 +112,15 @@
|
|||
<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>
|
||||
|
@ -397,8 +400,14 @@
|
|||
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 () {
|
||||
|
@ -417,8 +426,12 @@
|
|||
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");
|
||||
|
|
Loading…
Reference in a new issue