]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
intorduces a fallback format for relativeDate #17
authorPierre Spring <pierre@nelm.io>
Thu, 8 Dec 2011 08:11:40 +0000 (09:11 +0100)
committerPierre Spring <pierre@nelm.io>
Fri, 9 Dec 2011 12:52:48 +0000 (13:52 +0100)
lang/test/en.js
moment.js

index a31938f2dd2202d2fe6e5b2a7f1073f31434093c..4f45ef998e7ff122c5e57f0579d823a8a2391de9 100644 (file)
@@ -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;
 })
index 1cbdb7b499e1e8ad783e94f3cffd03a99019636d..14b27f8faf31cd1a83d127b347462fa2cbbb34d3 100644 (file)
--- a/moment.js
+++ b/moment.js
                 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 () {