Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 5 commits
  • 3 files changed
  • 0 commit comments
  • 2 contributors
Showing with 28 additions and 16 deletions.
  1. +9 −8 jquery.timeago.js
  2. +17 −4 test/index.html
  3. +2 −4 test/test_helpers.js
View
17 jquery.timeago.js
@@ -3,7 +3,7 @@
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
*
* @name timeago
- * @version 0.10.1
+ * @version 0.11.1
* @requires jQuery v1.2.3+
* @author Ryan McGeary
* @license MIT License - http://www.opensource.org/licenses/mit-license.php
@@ -77,14 +77,15 @@
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));
+ var separator = $l.wordSeparator === undefined ? " " : $l.wordSeparator;
+ return $.trim([prefix, words, suffix].join(separator));
},
parse: function(iso8601) {
var s = $.trim(iso8601);
View
21 test/index.html
@@ -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");
View
6 test/test_helpers.js
@@ -36,8 +36,7 @@ function loadPigLatin() {
month: "about-hay a-hay onth-may",
months: "%d onths-may",
year: "about-hay a-hay ear-yay",
- years: "%d years-yay",
- wordSeparator: " "
+ years: "%d years-yay"
};
}
@@ -72,8 +71,7 @@ function loadRussian() {
month: "месяц",
months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); },
year: "год",
- years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); },
- wordSeparator: " "
+ years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }
};
})();
}

No commit comments for this range

Something went wrong with that request. Please try again.