Merge pull request #3708 from tgxworld/fix_post_age_time

FIX: Post age time not being translated correctly.
This commit is contained in:
Régis Hanol 2015-08-30 20:12:44 +02:00
commit 6dba567001
2 changed files with 10 additions and 7 deletions

View File

@ -142,13 +142,13 @@ function relativeAgeTiny(date){
case(distanceInMinutes >= 45 && distanceInMinutes <= 89):
formatted = t("about_x_hours", {count: 1});
break;
case(distanceInMinutes >= 90 && distanceInMinutes <= 1439):
case(distanceInMinutes >= 90 && distanceInMinutes <= 1409):
formatted = t("about_x_hours", {count: Math.round(distanceInMinutes / 60.0)});
break;
case(Discourse.SiteSettings.relative_date_duration === 0 && distanceInMinutes <= 525599):
formatted = shortDateNoYear(date);
break;
case(distanceInMinutes >= 1440 && distanceInMinutes <= 2519):
case(distanceInMinutes >= 1410 && distanceInMinutes <= 2519):
formatted = t("x_days", {count: 1});
break;
case(distanceInMinutes >= 2520 && distanceInMinutes <= ((Discourse.SiteSettings.relative_date_duration||14) * 1440)):
@ -189,10 +189,10 @@ function relativeAgeMediumSpan(distance, leaveAgo) {
case(distanceInMinutes >= 56 && distanceInMinutes <= 89):
formatted = t("x_hours", {count: 1});
break;
case(distanceInMinutes >= 90 && distanceInMinutes <= 1379):
case(distanceInMinutes >= 90 && distanceInMinutes <= 1409):
formatted = t("x_hours", {count: Math.round(distanceInMinutes / 60.0)});
break;
case(distanceInMinutes >= 1380 && distanceInMinutes <= 2159):
case(distanceInMinutes >= 1410 && distanceInMinutes <= 2159):
formatted = t("x_days", {count: 1});
break;
case(distanceInMinutes >= 2160):
@ -266,4 +266,3 @@ export function number(val) {
}
return val.toString();
}

View File

@ -52,7 +52,8 @@ test("formating medium length dates", function() {
equal(strip(formatMins(56)), "1 hour ago");
equal(strip(formatHours(4)), "4 hours ago");
equal(strip(formatHours(22)), "22 hours ago");
equal(strip(formatHours(23)), "1 day ago");
equal(strip(formatHours(23)), "23 hours ago");
equal(strip(formatHours(23.5)), "1 day ago");
equal(strip(formatDays(4.85)), "4 days ago");
leaveAgo = false;
@ -63,7 +64,8 @@ test("formating medium length dates", function() {
equal(strip(formatMins(56)), "1 hour");
equal(strip(formatHours(4)), "4 hours");
equal(strip(formatHours(22)), "22 hours");
equal(strip(formatHours(23)), "1 day");
equal(strip(formatHours(23)), "23 hours");
equal(strip(formatHours(23.5)), "1 day");
equal(strip(formatDays(4.85)), "4 days");
equal(strip(formatDays(6)), shortDate(6));
@ -91,6 +93,8 @@ test("formating tiny dates", function() {
equal(formatMins(2), "2m");
equal(formatMins(60), "1h");
equal(formatHours(4), "4h");
equal(formatHours(23), "23h");
equal(formatHours(23.5), "1d");
equal(formatDays(1), "1d");
equal(formatDays(14), "14d");
equal(formatDays(15), shortDate(15));