mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Error in smart short date function
This commit is contained in:
parent
1643ff0f3c
commit
90330d30f4
@ -56,8 +56,8 @@ function shortDateNoYear(date) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Suppress year if it's this year
|
// Suppress year if it's this year
|
||||||
export function smartShortDate(date) {
|
export function smartShortDate(date, withYear=tinyDateYear) {
|
||||||
return (date.getFullYear() === new Date().getFullYear()) ? shortDateNoYear(date) : tinyDateYear(date);
|
return (date.getFullYear() === new Date().getFullYear()) ? shortDateNoYear(date) : withYear(date);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tinyDateYear(date) {
|
export function tinyDateYear(date) {
|
||||||
@ -220,7 +220,7 @@ function relativeAgeMedium(date, options) {
|
|||||||
if (distance < oneMinuteAgo) {
|
if (distance < oneMinuteAgo) {
|
||||||
displayDate = I18n.t("now");
|
displayDate = I18n.t("now");
|
||||||
} else if (distance > fiveDaysAgo) {
|
} else if (distance > fiveDaysAgo) {
|
||||||
displayDate = smartShortDate(date);
|
displayDate = smartShortDate(date, shortDate);
|
||||||
} else {
|
} else {
|
||||||
displayDate = relativeAgeMediumSpan(distance, leaveAgo);
|
displayDate = relativeAgeMediumSpan(distance, leaveAgo);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,6 @@ test("formating medium length dates", function() {
|
|||||||
|
|
||||||
equal(strip(formatDays(8)), shortDate(8));
|
equal(strip(formatDays(8)), shortDate(8));
|
||||||
equal(strip(formatDays(10)), shortDateYear(10));
|
equal(strip(formatDays(10)), shortDateYear(10));
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("formating tiny dates", function() {
|
test("formating tiny dates", function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user