Changes to tiny date format to remove mon and show short format dates instead
This commit is contained in:
parent
3c9cdead49
commit
2d6118297d
|
@ -4,7 +4,7 @@ Discourse.Formatter = (function(){
|
|||
|
||||
var updateRelativeAge, autoUpdatingRelativeAge, relativeAge, relativeAgeTiny,
|
||||
relativeAgeMedium, relativeAgeMediumSpan, longDate, toTitleCase,
|
||||
shortDate, breakUp;
|
||||
shortDate, shortDateNoYear, breakUp;
|
||||
|
||||
breakUp = function(string, maxLength){
|
||||
if(string.length <= maxLength) {
|
||||
|
@ -29,6 +29,10 @@ Discourse.Formatter = (function(){
|
|||
return moment(date).shortDate();
|
||||
};
|
||||
|
||||
shortDateNoYear = function(date) {
|
||||
return moment(date).shortDateNoYear();
|
||||
};
|
||||
|
||||
// http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript
|
||||
// TODO: locale support ?
|
||||
toTitleCase = function toTitleCase(str)
|
||||
|
@ -104,16 +108,16 @@ Discourse.Formatter = (function(){
|
|||
case(distanceInMinutes >= 1440 && distanceInMinutes <= 2519):
|
||||
formatted = t("x_days", {count: 1});
|
||||
break;
|
||||
case(distanceInMinutes >= 2520 && distanceInMinutes <= 129599):
|
||||
case(distanceInMinutes >= 2520 && distanceInMinutes <= 20160):
|
||||
formatted = t("x_days", {count: Math.round(distanceInMinutes / 1440.0)});
|
||||
break;
|
||||
case(distanceInMinutes >= 129600 && distanceInMinutes <= 525599):
|
||||
formatted = t("x_months", {count: Math.round(distanceInMinutes / 43200.0)});
|
||||
case(distanceInMinutes >= 20160 && distanceInMinutes <= 525599):
|
||||
formatted = shortDateNoYear(date);
|
||||
break;
|
||||
default:
|
||||
var months = Math.round(distanceInMinutes / 43200.0);
|
||||
if (months < 24) {
|
||||
formatted = t("x_months", {count: months});
|
||||
if (months < 12) {
|
||||
formatted = shortDateNoYear(date);
|
||||
} else {
|
||||
formatted = t("over_x_years", {count: Math.round(months / 12.0)});
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@
|
|||
}
|
||||
}
|
||||
.main-link {
|
||||
width: 515px;
|
||||
width: 495px;
|
||||
font-size: 16px;
|
||||
|
||||
i.score {
|
||||
|
@ -132,12 +132,12 @@
|
|||
|
||||
@include medium-width {
|
||||
.main-link {
|
||||
width: 400px;
|
||||
width: 380px;
|
||||
}
|
||||
}
|
||||
@include small-width {
|
||||
.main-link {
|
||||
width: 355px;
|
||||
width: 335px;
|
||||
}
|
||||
}
|
||||
.topic-statuses:empty {
|
||||
|
@ -178,6 +178,9 @@
|
|||
color: inherit;
|
||||
}
|
||||
}
|
||||
.activity {
|
||||
width: 50px;
|
||||
}
|
||||
}
|
||||
|
||||
// Category list
|
||||
|
|
|
@ -28,12 +28,6 @@ en:
|
|||
x_days:
|
||||
one: "1d"
|
||||
other: "%{count}d"
|
||||
about_x_months:
|
||||
one: "1mon"
|
||||
other: "%{count}mon"
|
||||
x_months:
|
||||
one: "1mon"
|
||||
other: "%{count}mon"
|
||||
about_x_years:
|
||||
one: "1y"
|
||||
other: "%{count}y"
|
||||
|
|
|
@ -22,6 +22,10 @@ var formatMonths = function(months) {
|
|||
return formatDays(months * 30);
|
||||
};
|
||||
|
||||
var shortDate = function(days){
|
||||
return moment().subtract('days', days).format('D MMM');
|
||||
};
|
||||
|
||||
test("formating medium length dates", function() {
|
||||
|
||||
format = "medium";
|
||||
|
@ -29,10 +33,6 @@ test("formating medium length dates", function() {
|
|||
return $(html).text();
|
||||
};
|
||||
|
||||
var shortDate = function(days){
|
||||
return moment().subtract('days', days).format('D MMM');
|
||||
};
|
||||
|
||||
var shortDateYear = function(days){
|
||||
return moment().subtract('days', days).format('D MMM, YYYY');
|
||||
};
|
||||
|
@ -74,10 +74,13 @@ test("formating tiny dates", function() {
|
|||
equal(formatMins(60), "1h");
|
||||
equal(formatHours(4), "4h");
|
||||
equal(formatDays(1), "1d");
|
||||
equal(formatDays(20), "20d");
|
||||
equal(formatMonths(3), "3mon");
|
||||
equal(formatMonths(23), "23mon");
|
||||
equal(formatMonths(24), "> 2y");
|
||||
equal(formatDays(14), "14d");
|
||||
equal(formatDays(15), shortDate(15));
|
||||
equal(formatDays(92), shortDate(92));
|
||||
equal(formatDays(364), shortDate(364));
|
||||
equal(formatDays(365), "> 1y");
|
||||
equal(formatDays(500), "> 1y");
|
||||
equal(formatDays(365*2), "> 2y");
|
||||
});
|
||||
|
||||
test("autoUpdatingRelativeAge", function() {
|
||||
|
|
Loading…
Reference in New Issue