From: Iskren Ivov Chernev Date: Thu, 19 Jun 2014 06:02:11 +0000 (-0700) Subject: Merge pull request #1642 from ichernev/fix-humanize X-Git-Tag: 2.8.0~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc84a173db84f43a7b9b7e0d2da8df4dcb42dc36;p=thirdparty%2Fmoment.git Merge pull request #1642 from ichernev/fix-humanize 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). --- bc84a173db84f43a7b9b7e0d2da8df4dcb42dc36 diff --cc test/moment/relative_time.js index 6e00f5b5b,54804c1bd..23258733b --- a/test/moment/relative_time.js +++ b/test/moment/relative_time.js @@@ -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(); } };