From: Tim Wood Date: Thu, 3 May 2012 16:33:53 +0000 (-0700) Subject: Fixing moment.humanizeDuration(60000, true); syntax X-Git-Tag: 1.6.2^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fbe5728899952ef8ed6aea5c75777f9205f033a4;p=thirdparty%2Fmoment.git Fixing moment.humanizeDuration(60000, true); syntax Yeah, it's ugly, but it will be deprecated in 1.7.0 anyway… #299 --- diff --git a/moment.js b/moment.js index 08b3f49ab..c76c3f23c 100644 --- a/moment.js +++ b/moment.js @@ -620,7 +620,7 @@ // 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 diff --git a/test/moment/humanize_duration.js b/test/moment/humanize_duration.js index a5f775241..b539851f5 100644 --- a/test/moment/humanize_duration.js +++ b/test/moment/humanize_duration.js @@ -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(); } };