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