From: Eric Hartford Date: Tue, 26 Nov 2013 19:37:50 +0000 (-0800) Subject: change name of quarterOfYear to quarter X-Git-Tag: 2.5.0^2~26^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=20542430b47242bd25d81fe4ddd59f5e68bc05cf;p=thirdparty%2Fmoment.git change name of quarterOfYear to quarter --- diff --git a/moment.js b/moment.js index 72b357eaa..0b0e8a158 100644 --- a/moment.js +++ b/moment.js @@ -248,7 +248,7 @@ return this.unix(); }, Q : function () { - return this.quarterOfYear(); + return this.quarter(); } }, @@ -2016,7 +2016,7 @@ return input == null ? dayOfYear : this.add("d", (input - dayOfYear)); }, - quarterOfYear : function () { + quarter : function () { return Math.ceil((this.month() + 1.0) / 3.0); }, diff --git a/test/moment/quarter.js b/test/moment/quarter.js new file mode 100644 index 000000000..a98de1baa --- /dev/null +++ b/test/moment/quarter.js @@ -0,0 +1,17 @@ +var moment = require("../../moment"); + +exports.quarter = { + "library quarter" : function (test) { + test.expect(7); + + test.equal(moment([1985, 1, 4]).quarter(), 1, "Feb 4 1985 is Q1"); + test.equal(moment([2029, 8, 18]).quarter(), 3, "Sep 18 2029 is Q3"); + test.equal(moment([2013, 3, 24]).quarter(), 2, "Apr 24 2013 is Q2"); + test.equal(moment([2015, 2, 5]).quarter(), 1, "Mar 5 2015 is Q1"); + test.equal(moment([1970, 0, 2]).quarter(), 1, "Jan 2 1970 is Q1"); + test.equal(moment([2001, 11, 12]).quarter(), 4, "Dec 12 2001 is Q4"); + test.equal(moment([2000, 0, 2]).quarter(), 1, "Jan 2 2000 is Q1"); + + test.done(); + } +};