Sha256: c4a80a5b2d04d2053865769b4dffbb04b7132d76191b29693a360106412f2001

Contents?: true

Size: 725 Bytes

Versions: 9

Compression:

Stored size: 725 Bytes

Contents

import { createLocal } from '../create/local';
import { cloneWithOffset } from '../units/offset';

export function calendar (time) {
    // 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(),
        sod = cloneWithOffset(now, this).startOf('day'),
        diff = this.diff(sod, 'days', true),
        format = diff < -6 ? 'sameElse' :
            diff < -1 ? 'lastWeek' :
            diff < 0 ? 'lastDay' :
            diff < 1 ? 'sameDay' :
            diff < 2 ? 'nextDay' :
            diff < 7 ? 'nextWeek' : 'sameElse';
    return this.format(this.localeData().calendar(format, this, createLocal(now)));
}

Version data entries

9 entries across 9 versions & 3 rubygems

Version Path
sedge_cms-0.0.1 vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.6 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.5 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.4 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.3 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.2 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
date_picker-0.0.1 test/dummy/vendor/assets/components/moment/src/lib/moment/calendar.js
puppet-herald-0.8.1 lib/puppet-herald/public/bower_components/moment/src/lib/moment/calendar.js
puppet-herald-0.8.0 lib/puppet-herald/public/bower_components/moment/src/lib/moment/calendar.js