]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Fixing moment.humanizeDuration(60000, true); syntax
authorTim Wood <washwithcare@gmail.com>
Thu, 3 May 2012 16:33:53 +0000 (09:33 -0700)
committerTim Wood <washwithcare@gmail.com>
Thu, 3 May 2012 16:33:53 +0000 (09:33 -0700)
Yeah, it's ugly, but it will be deprecated in 1.7.0 anyway…
#299

moment.js
test/moment/humanize_duration.js

index 08b3f49aba7314873178775dd4f92f3c870037cf..c76c3f23cf1ef149c78d0e9e8e7706df6271311f 100644 (file)
--- a/moment.js
+++ b/moment.js
     // This method is deprecated in favor of the new Duration object.  Please
     // see the moment.duration method.
     moment.humanizeDuration = function (num, type, withSuffix) {
-        return moment.duration(num, type).humanize(withSuffix);
+        return moment.duration(num, type === true ? null : type).humanize(type === true ? true : withSuffix);
     };
 
     // version number
index a5f775241b561854bf201408f6037e8dac3fb5e0..b539851f51a203a22629f163e93ba04f2e729965 100644 (file)
@@ -42,10 +42,11 @@ exports.humanize_duration = {
     },
 
     "humanize duration with suffix" : function(test) {
-        test.expect(2);
+        test.expect(3);
         moment.lang('en');
         test.equal(moment.humanizeDuration(44, "seconds", true),  "in a few seconds", "44 seconds = a few seconds");
         test.equal(moment.humanizeDuration(-44, "seconds", true),  "a few seconds ago", "44 seconds = a few seconds");
+        test.equal(moment.humanizeDuration(44000, true),  "in a few seconds", "44000 milliseconds = a few seconds");
         test.done();
     }
 };