]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Merge pull request #1642 from ichernev/fix-humanize
authorIskren Ivov Chernev <iskren.chernev@gmail.com>
Thu, 19 Jun 2014 06:02:11 +0000 (23:02 -0700)
committerIskren Ivov Chernev <iskren.chernev@gmail.com>
Thu, 19 Jun 2014 06:02:11 +0000 (23:02 -0700)
Fix humanize

@changelog
@section bugfix
@description use duration object for relative duration strings
@breaking relativeTimeThreshold keys are now changed to 's', 'm', 'h', 'd' and 'M'. Also the actual thresholds for changed (46 days is now 1 month, not 2).

1  2 
moment.js
test/moment/relative_time.js

diff --cc moment.js
Simple merge
index 6e00f5b5bfdb28856d9fa9edc2993e26358db6ca,54804c1bd5084ea2be34d476ec76eb315f2954bb..23258733bffe8d6fd83696da864c7174bd87a5b0
@@@ -85,42 -71,23 +71,33 @@@ exports.relativeTime = 
          test.equal(a.fromNow(), "a day ago", "Above custom hours to days threshold");
          moment.relativeTimeThreshold('h', 22);
  
-         // Days to month (singluar) threshold
-         moment.relativeTimeThreshold('dd', 28);
+         // Days to month threshold
+         moment.relativeTimeThreshold('d', 28);
          a = moment();
-         a.subtract('days', 28);
-         test.equal(a.fromNow(), "28 days ago", "Below custom days to month (singular) threshold");
+         a.subtract('days', 27);
+         test.equal(a.fromNow(), "27 days ago", "Below custom days to month (singular) threshold");
          a.subtract('days', 1);
          test.equal(a.fromNow(), "a month ago", "Above custom days to month (singular) threshold");
-         moment.relativeTimeThreshold('dd', 25);
-         // Days to months (plural) threshold
-         moment.relativeTimeThreshold('dm', 55);
-         a = moment();
-         a.subtract('days', 55);
-         test.equal(a.fromNow(), "a month ago", "Above custom days to months (plural) threshold");
-         a.subtract('days', 1);
-         test.equal(a.fromNow(), "2 months ago", "Below custom days to months (plural) threshold");
-         moment.relativeTimeThreshold('dm', 45);
+         moment.relativeTimeThreshold('d', 26);
  
-         // Days to years threshold
-         moment.relativeTimeThreshold('dy', 360);
+         // months to years threshold
+         moment.relativeTimeThreshold('M', 9);
          a = moment();
-         a.subtract('days', 359);
-         test.equal(a.fromNow(), "12 months ago", "Below custom days to years threshold");
-         a.subtract('days', 1);
+         a.subtract('months', 8);
+         test.equal(a.fromNow(), "8 months ago", "Below custom days to years threshold");
+         a.subtract('months', 1);
          test.equal(a.fromNow(), "a year ago", "Above custom days to years threshold");
-         moment.relativeTimeThreshold('dy', 345);
+         moment.relativeTimeThreshold('M', 11);
 +        test.done();
 +    },
 +
 +    "retrive threshold settings" : function (test) {
 +        test.expect(1);
 +        moment.relativeTimeThreshold('m', 45);
 +        var minuteThreshold = moment.relativeTimeThreshold('m');
 +
 +        test.equal(minuteThreshold, 45, "Can retrieve minute setting");
 +
          test.done();
      }
  };