From: Pierre Spring Date: Thu, 8 Dec 2011 08:11:40 +0000 (+0100) Subject: intorduces a fallback format for relativeDate #17 X-Git-Tag: 1.3.0~33^2~5^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b1fec798cfbc56bc87ae9a540f0a106ac1e9f470;p=thirdparty%2Fmoment.git intorduces a fallback format for relativeDate #17 --- diff --git a/lang/test/en.js b/lang/test/en.js index a31938f2d..4f45ef998 100644 --- a/lang/test/en.js +++ b/lang/test/en.js @@ -144,7 +144,7 @@ test("fromNow", 2, function() { equal(moment().add({d:5}).fromNow(), "in 5 days", "in 5 days"); }); -test("relativeDate", 14, function() { +test("relativeDate", 15, function() { var getTodayAtTwo, prefixDay; getTodayAtTwo = function () { @@ -217,5 +217,12 @@ test("relativeDate", 14, function() { getTodayAtTwo().subtract({ w: 2 }).format('L'), "before 2 weeks at the same time" ); - + + moment.relativeDate.else = 'LLL'; + equal( + getTodayAtTwo().subtract({ w: 2 }).relativeDate(), + getTodayAtTwo().subtract({ w: 2 }).format('LLL'), + "before 2 weeks at the same time with custom format" + ); + delete moment.relativeDate.else; }) diff --git a/moment.js b/moment.js index 4437d79c9..6a8537e71 100644 --- a/moment.js +++ b/moment.js @@ -570,7 +570,7 @@ return moment.relativeDate[arrayKey].replace('%weekday', this.format('dddd')).replace('%time', this.format('XXXX')); } - return this.format('L'); + return this.format(moment.relativeDate.else || 'L'); }, isLeapYear : function () {