]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
change name of quarterOfYear to quarter 1311/head
authorEric Hartford <ericstob@gmail.com>
Tue, 26 Nov 2013 19:37:50 +0000 (11:37 -0800)
committerEric Hartford <ericstob@gmail.com>
Tue, 26 Nov 2013 19:37:50 +0000 (11:37 -0800)
moment.js
test/moment/quarter.js [new file with mode: 0644]

index 72b357eaa52ed0c126dff8c89878f28125c656c0..0b0e8a1589dcedf8eb7cbe1ecf3c4b69dd3c4adf 100644 (file)
--- a/moment.js
+++ b/moment.js
                 return this.unix();
             },
             Q : function () {
-                return this.quarterOfYear();
+                return this.quarter();
             }
         },
 
             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 (file)
index 0000000..a98de1b
--- /dev/null
@@ -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();
+    }
+};