+import { isMoment } from './constructor';
import { createLocal } from '../create/local';
import { cloneWithOffset } from '../units/offset';
import isFunction from '../utils/is-function';
}
export function calendar (time, formats) {
+ // #3658 - Adding overload to the calendar function in order to allow:
+ // calendar(FORMATS) a single parameter, formats only function call
+ if (arguments.length === 1 && typeof time === 'object' && !isMoment(time)) {
+ formats = arguments[0];
+ time = undefined;
+ }
// We want to compare the start of today, vs this.
// Getting start-of-today depends on whether we're local/utc/offset or not.
var now = time || createLocal(),
moment.updateLocale('en', null);
}
});
+
+test('calendar overload - passing one parameter formats', function (assert) {
+ var a = moment().hours(13).minutes(23).seconds(45);
+ assert.equal(moment(a).calendar({
+ 'sameDay': function () {
+ return 'h:mm:ssA';
+ }
+ }), '1:23:45PM', 'should equate');
+
+});