return this.from(moment(), withoutSuffix);
},
- calendar : function () {
+ calendar : function (time) {
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're zone'd or not.
- var sod = makeAs(moment(), this).startOf('day'),
+ var now = time || moment(),
+ sod = makeAs(now, this).startOf('day'),
diff = this.diff(sod, 'days', true),
format = diff < -6 ? 'sameElse' :
diff < -1 ? 'lastWeek' :
},
"calendar day timezone" : function (test) {
- test.expect(10);
+ test.expect(11);
moment.lang('en');
var zones = [60, -60, 90, -90, 360, -360, 720, -720],
b = moment().utc().startOf('day').subtract({ m : 1 }),
c = moment().local().startOf('day').subtract({ m : 1 }),
+ d = moment().local().startOf('day').subtract({ d : 2 }),
i, z, a;
for (i = 0; i < zones.length; ++i) {
test.equal(moment(b).utc().calendar(), "Yesterday at 11:59 PM", "Yesterday at 11:59 PM, not Today, or the wrong time");
test.equal(moment(c).local().calendar(), "Yesterday at 11:59 PM", "Yesterday at 11:59 PM, not Today, or the wrong time");
+ test.equal(moment(c).local().calendar(d), "Tomorrow at 11:59 PM", "Tomorrow at 11:59 PM, not Yesterday, or the wrong time");
test.done();
},