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();
}
};