UNPKG

ngx-bootstrap

Version:
1,739 lines 126 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ import * as tslib_1 from "tslib"; // tslint:disable:max-line-length max-file-line-count import { add, subtract } from '../index'; import { getDate, getFullYear, getHours, getMilliseconds, getMinutes, getMonth, getSeconds } from '../utils/date-getters'; import { setDate, setFullYear, setHours, setMilliseconds, setMinutes, setMonth, setSeconds } from '../utils/date-setters'; import { cloneDate } from '../create/clone'; import { isArray, isBoolean, isDate, isDateValid, isFunction, isNumber, isObject, isString, isUndefined } from '../utils/type-checks'; import { formatDate } from '../format'; import { ISO_8601, RFC_2822 } from '../create/from-string-and-format'; import { getDateOffset, getUTCOffset, hasAlignedHourOffset, isDaylightSavingTime, setOffsetToParsedOffset, setUTCOffset } from '../units/offset'; import { isLeapYear, parseTwoDigitYear } from '../units/year'; import { isAfter, isBefore, isBetween, isSame, isSameOrAfter, isSameOrBefore } from '../utils/date-compare'; import { daysInMonth } from '../units/month'; import { getDayOfWeek, getISODayOfWeek, getLocaleDayOfWeek, parseWeekday, setDayOfWeek, setISODayOfWeek, setLocaleDayOfWeek } from '../units/day-of-week'; import { getISOWeek, getWeek, setISOWeek, setWeek } from '../units/week'; import { getISOWeeksInYear, getISOWeekYear, getSetISOWeekYear, getSetWeekYear, getWeeksInYear, getWeekYear } from '../units/week-year'; import { endOf, startOf } from '../utils/start-end-of'; import { getQuarter, setQuarter } from '../units/quarter'; import { getDayOfYear, setDayOfYear } from '../units/day-of-year'; import { getZoneAbbr, getZoneName } from '../units/timezone'; import { diff } from '../moment/diff'; import { calendar } from '../moment/calendar'; import { defineLocale, getLocale, getSetGlobalLocale, listLocales } from '../locale/locales'; import { max, min } from '../moment/min-max'; import { isDuration } from '../duration/constructor'; import { createLocalOrUTC } from '../create/from-anything'; import { createDuration } from '../duration/create'; /** @type {?} */ export var moment = ((/** @type {?} */ (_moment))); /** * @record */ export function MomentFn() { } if (false) { /** @type {?} */ MomentFn.prototype.ISO_8601; /** @type {?} */ MomentFn.prototype.RFC_2822; /* Skipping unhandled member: (input?: DateInput | Khronos, format?: string | string[], localeKey?: string | boolean, strict?: boolean, isUTC?: boolean): Khronos;*/ /** * @param {?=} input * @param {?=} format * @param {?=} localeKey * @param {?=} strict * @return {?} */ MomentFn.prototype.utc = function (input, format, localeKey, strict) { }; /** * @param {?=} input * @param {?=} format * @param {?=} localeKey * @param {?=} strict * @return {?} */ MomentFn.prototype.parseZone = function (input, format, localeKey, strict) { }; /** * @param {?} num * @return {?} */ MomentFn.prototype.unix = function (num) { }; /** * @param {?=} key * @param {?=} values * @return {?} */ MomentFn.prototype.locale = function (key, values) { }; /** * @param {?=} inp * @param {?=} unit * @return {?} */ MomentFn.prototype.duration = function (inp, unit) { }; /** * @param {?} name * @param {?=} config * @return {?} */ MomentFn.prototype.defineLocale = function (name, config) { }; /** * @param {?} input * @return {?} */ MomentFn.prototype.parseTwoDigitYear = function (input) { }; /** * @param {?=} input * @return {?} */ MomentFn.prototype.isDate = function (input) { }; /** * @return {?} */ MomentFn.prototype.months = function () { }; /** * @param {?} index * @return {?} */ MomentFn.prototype.months = function (index) { }; /** * @param {?} format * @return {?} */ MomentFn.prototype.months = function (format) { }; /** * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.months = function (format, index) { }; /** * @return {?} */ MomentFn.prototype.monthsShort = function () { }; /** * @param {?} index * @return {?} */ MomentFn.prototype.monthsShort = function (index) { }; /** * @param {?} format * @return {?} */ MomentFn.prototype.monthsShort = function (format) { }; /** * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.monthsShort = function (format, index) { }; /** * @return {?} */ MomentFn.prototype.weekdays = function () { }; /** * @param {?} index * @return {?} */ MomentFn.prototype.weekdays = function (index) { }; /** * @param {?} format * @return {?} */ MomentFn.prototype.weekdays = function (format) { }; /** * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdays = function (format, index) { }; /** * @param {?} localeSorted * @return {?} */ MomentFn.prototype.weekdays = function (localeSorted) { }; /** * @param {?} localeSorted * @param {?} index * @return {?} */ MomentFn.prototype.weekdays = function (localeSorted, index) { }; /** * @param {?} localeSorted * @param {?} format * @return {?} */ MomentFn.prototype.weekdays = function (localeSorted, format) { }; /** * @param {?} localeSorted * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdays = function (localeSorted, format, index) { }; /** * @return {?} */ MomentFn.prototype.weekdaysShort = function () { }; /** * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysShort = function (index) { }; /** * @param {?} format * @return {?} */ MomentFn.prototype.weekdaysShort = function (format) { }; /** * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysShort = function (format, index) { }; /** * @param {?} localeSorted * @return {?} */ MomentFn.prototype.weekdaysShort = function (localeSorted) { }; /** * @param {?} localeSorted * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysShort = function (localeSorted, index) { }; /** * @param {?} localeSorted * @param {?} format * @return {?} */ MomentFn.prototype.weekdaysShort = function (localeSorted, format) { }; /** * @param {?} localeSorted * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysShort = function (localeSorted, format, index) { }; /** * @return {?} */ MomentFn.prototype.weekdaysMin = function () { }; /** * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysMin = function (index) { }; /** * @param {?} format * @return {?} */ MomentFn.prototype.weekdaysMin = function (format) { }; /** * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysMin = function (format, index) { }; /** * @param {?} localeSorted * @return {?} */ MomentFn.prototype.weekdaysMin = function (localeSorted) { }; /** * @param {?} localeSorted * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysMin = function (localeSorted, index) { }; /** * @param {?} localeSorted * @param {?} format * @return {?} */ MomentFn.prototype.weekdaysMin = function (localeSorted, format) { }; /** * @param {?} localeSorted * @param {?} format * @param {?} index * @return {?} */ MomentFn.prototype.weekdaysMin = function (localeSorted, format, index) { }; /** * @param {?} threshold * @return {?} */ MomentFn.prototype.relativeTimeThreshold = function (threshold) { }; /** * @param {?} threshold * @param {?} limit * @return {?} */ MomentFn.prototype.relativeTimeThreshold = function (threshold, limit) { }; /** * @param {...?} dates * @return {?} */ MomentFn.prototype.min = function (dates) { }; /** * @param {...?} dates * @return {?} */ MomentFn.prototype.max = function (dates) { }; /** * @param {?=} key * @return {?} */ MomentFn.prototype.localeData = function (key) { }; /** * @param {?} language * @param {?=} localeSpec * @return {?} */ MomentFn.prototype.updateLocale = function (language, localeSpec) { }; /** * @param {?} m * @param {?} now * @return {?} */ MomentFn.prototype.calendarFormat = function (m, now) { }; /** * @param {?} m * @param {?} now * @return {?} */ MomentFn.prototype.calendarFormat = function (m, now) { }; /** * @return {?} */ MomentFn.prototype.invalid = function () { }; /** * @return {?} */ MomentFn.prototype.locales = function () { }; /** * @param {?} m * @param {?=} keepTime * @return {?} */ MomentFn.prototype.updateOffset = function (m, keepTime) { }; } /** * @param {?=} input * @param {?=} format * @param {?=} localeKey * @param {?=} strict * @param {?=} isUTC * @return {?} */ function _moment(input, format, localeKey, strict, isUTC) { if (input instanceof Khronos) { /** @type {?} */ var _date = input.clone(); return isUTC ? _date.utc() : _date; } if (isBoolean(localeKey)) { return new Khronos(input, format, null, localeKey, isUTC); } return new Khronos(input, format, localeKey, strict, isUTC); } moment.utc = function (input, format, localeKey, strict) { return _moment(input, format, localeKey, strict, true); }; moment.parseZone = function (input, format, localeKey, strict) { return _moment(input, format, localeKey, strict, true).parseZone(); }; moment.locale = getSetGlobalLocale; moment.localeData = function (key) { if (key instanceof Khronos) { return key.localeData(); } return getLocale(key); }; // moment.utc = createUTC; moment.unix = function (inp) { return new Khronos(inp * 1000); }; moment.ISO_8601 = ISO_8601; moment.RFC_2822 = RFC_2822; moment.defineLocale = defineLocale; moment.parseTwoDigitYear = parseTwoDigitYear; moment.isDate = isDate; moment.invalid = function _invalid() { return new Khronos(new Date(NaN)); }; // duration(inp?: Duration | DateInput | Khronos, unit?: MomentUnitOfTime): Duration; moment.duration = function (input, unit) { /** @type {?} */ var _unit = mapUnitOfTime(unit); if (isDate(input)) { throw new Error('todo implement'); } if (input == null) { return createDuration(); } if (isDuration(input)) { return createDuration(input, _unit, { _locale: input._locale }); } if (isString(input) || isNumber(input) || isDuration(input) || isObject(input)) { return createDuration(input, _unit); } throw new Error('todo implement'); }; moment.min = function _min() { var dates = []; for (var _i = 0; _i < arguments.length; _i++) { dates[_i] = arguments[_i]; } /** @type {?} */ var _firstArg = dates[0]; /** @type {?} */ var _dates = (isArray(_firstArg) ? _firstArg : dates) // tslint:disable-next-line .map(function (date) { return _moment(date); }) .map(function (date) { return date.toDate(); }); /** @type {?} */ var _date = min.apply(void 0, tslib_1.__spread(_dates)); return new Khronos(_date); }; moment.max = function _max() { var dates = []; for (var _i = 0; _i < arguments.length; _i++) { dates[_i] = arguments[_i]; } /** @type {?} */ var _firstArg = dates[0]; /** @type {?} */ var _dates = (isArray(_firstArg) ? _firstArg : dates) // tslint:disable-next-line .map(function (date) { return _moment(date); }) .map(function (date) { return date.toDate(); }); /** @type {?} */ var _date = max.apply(void 0, tslib_1.__spread(_dates)); return new Khronos(_date); }; moment.locales = function () { return listLocales(); }; /** * @record */ export function MomentInputObject() { } if (false) { /** @type {?|undefined} */ MomentInputObject.prototype.years; /** @type {?|undefined} */ MomentInputObject.prototype.year; /** @type {?|undefined} */ MomentInputObject.prototype.y; /** @type {?|undefined} */ MomentInputObject.prototype.months; /** @type {?|undefined} */ MomentInputObject.prototype.month; /** @type {?|undefined} */ MomentInputObject.prototype.M; /** @type {?|undefined} */ MomentInputObject.prototype.days; /** @type {?|undefined} */ MomentInputObject.prototype.day; /** @type {?|undefined} */ MomentInputObject.prototype.d; /** @type {?|undefined} */ MomentInputObject.prototype.dates; /** @type {?|undefined} */ MomentInputObject.prototype.date; /** @type {?|undefined} */ MomentInputObject.prototype.D; /** @type {?|undefined} */ MomentInputObject.prototype.hours; /** @type {?|undefined} */ MomentInputObject.prototype.hour; /** @type {?|undefined} */ MomentInputObject.prototype.h; /** @type {?|undefined} */ MomentInputObject.prototype.minutes; /** @type {?|undefined} */ MomentInputObject.prototype.minute; /** @type {?|undefined} */ MomentInputObject.prototype.m; /** @type {?|undefined} */ MomentInputObject.prototype.seconds; /** @type {?|undefined} */ MomentInputObject.prototype.second; /** @type {?|undefined} */ MomentInputObject.prototype.s; /** @type {?|undefined} */ MomentInputObject.prototype.milliseconds; /** @type {?|undefined} */ MomentInputObject.prototype.millisecond; /** @type {?|undefined} */ MomentInputObject.prototype.ms; /** @type {?|undefined} */ MomentInputObject.prototype.w; /** @type {?|undefined} */ MomentInputObject.prototype.week; /** @type {?|undefined} */ MomentInputObject.prototype.weeks; /** @type {?|undefined} */ MomentInputObject.prototype.Q; /** @type {?|undefined} */ MomentInputObject.prototype.quarter; /** @type {?|undefined} */ MomentInputObject.prototype.quarters; /** @type {?|undefined} */ MomentInputObject.prototype.weekYear; } /** @type {?} */ var _unitsPriority = { year: 1, month: 8, week: 5, isoWeek: 5, day: 11, weekday: 11, isoWeekday: 11, hours: 13, weekYear: 1, isoWeekYear: 1, quarter: 7, date: 9, dayOfYear: 4, minutes: 14, seconds: 15, milliseconds: 16 }; // todo: do I need 2 mappers? /** @type {?} */ var _timeHashMap = { y: 'year', years: 'year', year: 'year', M: 'month', months: 'month', month: 'month', w: 'week', weeks: 'week', week: 'week', d: 'day', days: 'day', day: 'day', date: 'date', dates: 'date', D: 'date', h: 'hours', hour: 'hours', hours: 'hours', m: 'minutes', minute: 'minutes', minutes: 'minutes', s: 'seconds', second: 'seconds', seconds: 'seconds', ms: 'milliseconds', millisecond: 'milliseconds', milliseconds: 'milliseconds', quarter: 'quarter', quarters: 'quarter', q: 'quarter', Q: 'quarter', isoWeek: 'isoWeek', isoWeeks: 'isoWeek', W: 'isoWeek', weekYear: 'weekYear', weekYears: 'weekYear', gg: 'weekYears', isoWeekYear: 'isoWeekYear', isoWeekYears: 'isoWeekYear', GG: 'isoWeekYear', dayOfYear: 'dayOfYear', dayOfYears: 'dayOfYear', DDD: 'dayOfYear', weekday: 'weekday', weekdays: 'weekday', e: 'weekday', isoWeekday: 'isoWeekday', isoWeekdays: 'isoWeekday', E: 'isoWeekday' }; /** * @param {?} period * @return {?} */ function mapUnitOfTime(period) { return (/** @type {?} */ (_timeHashMap[period])); } /** * @param {?} obj * @return {?} */ function mapMomentInputObject(obj) { /** @type {?} */ var _res = {}; return Object.keys(obj) .reduce(function (res, key) { res[mapUnitOfTime(key)] = obj[key]; return res; }, _res); } var Khronos = /** @class */ (function () { function Khronos(input, format, localeKey, strict, isUTC, offset) { if (strict === void 0) { strict = false; } if (isUTC === void 0) { isUTC = false; } this._date = new Date(); this._isUTC = false; // locale will be needed to format invalid date message this._locale = getLocale(localeKey); // parse invalid input if (input === '' || input === null || (isNumber(input) && isNaN(input))) { this._date = new Date(NaN); return this; } this._isUTC = isUTC; if (this._isUTC) { this._offset = 0; } if (offset || offset === 0) { this._offset = offset; } this._isStrict = strict; this._format = format; if (!input && input !== 0 && !format) { this._date = new Date(); return this; } if (isDate(input)) { this._date = cloneDate(input); return this; } // this._date = parseDate(input, format, localeKey, strict, isUTC); /** @type {?} */ var config = createLocalOrUTC(input, format, localeKey, strict, isUTC); this._date = config._d; this._offset = isNumber(config._offset) ? config._offset : this._offset; this._isUTC = config._isUTC; this._isStrict = config._strict; this._format = config._f; this._tzm = config._tzm; } /** * @return {?} */ Khronos.prototype._toConfig = /** * @return {?} */ function () { return { _isUTC: this._isUTC, _locale: this._locale, _offset: this._offset, _tzm: this._tzm }; }; /** * @param {?=} localeKey * @return {?} */ Khronos.prototype.locale = /** * @param {?=} localeKey * @return {?} */ function (localeKey) { if (isUndefined(localeKey)) { return this._locale._abbr; } if (localeKey instanceof Khronos) { this._locale = localeKey._locale; return this; } /** @type {?} */ var newLocaleData = getLocale(localeKey); if (newLocaleData != null) { this._locale = newLocaleData; } return this; }; /** * @return {?} */ Khronos.prototype.localeData = /** * @return {?} */ function () { return this._locale; }; // Basic // Basic /** * @param {?} val * @param {?=} period * @return {?} */ Khronos.prototype.add = // Basic /** * @param {?} val * @param {?=} period * @return {?} */ function (val, period) { var _this = this; if (isString(val)) { this._date = add(this._date, parseInt(val, 10), mapUnitOfTime(period)); } if (isNumber(val)) { this._date = add(this._date, val, mapUnitOfTime(period)); } if (isObject(val)) { /** @type {?} */ var _mapped_1 = mapMomentInputObject(val); Object.keys(_mapped_1) .forEach(function (key) { return add(_this._date, _mapped_1[key], key); }); } return this; }; // fixme: for some reason here 'null' for time is fine // fixme: for some reason here 'null' for time is fine /** * @param {?=} time * @param {?=} formats * @return {?} */ Khronos.prototype.calendar = // fixme: for some reason here 'null' for time is fine /** * @param {?=} time * @param {?=} formats * @return {?} */ function (time, formats) { /** @type {?} */ var _time = time instanceof Khronos ? time : new Khronos(time || new Date()); /** @type {?} */ var _offset = (this._offset || 0) - (_time._offset || 0); /** @type {?} */ var _config = Object.assign(this._toConfig(), { _offset: _offset }); return calendar(this._date, _time._date, formats, this._locale, _config); }; /** * @return {?} */ Khronos.prototype.clone = /** * @return {?} */ function () { /** @type {?} */ var localeKey = this._locale && this._locale._abbr || 'en'; // return new Khronos(cloneDate(this._date), this._format, localeKey, this._isStrict, this._isUTC); // fails if isUTC and offset // return new Khronos(new Date(this.valueOf()), return new Khronos(this._date, this._format, localeKey, this._isStrict, this._isUTC, this._offset); }; /** * @param {?} b * @param {?=} unitOfTime * @param {?=} precise * @return {?} */ Khronos.prototype.diff = /** * @param {?} b * @param {?=} unitOfTime * @param {?=} precise * @return {?} */ function (b, unitOfTime, precise) { /** @type {?} */ var unit = mapUnitOfTime(unitOfTime); /** @type {?} */ var _b = b instanceof Khronos ? b : new Khronos(b); // const zoneDelta = (_b.utcOffset() - this.utcOffset()); // const config = Object.assign(this._toConfig(), { // _offset: 0, // _isUTC: true, // _zoneDelta: zoneDelta // }); // return diff(new Date(this.valueOf()), new Date(_b.valueOf()), unit, precise, config); return diff(this._date, _b.toDate(), unit, precise, this._toConfig()); }; /** * @param {?=} period * @return {?} */ Khronos.prototype.endOf = /** * @param {?=} period * @return {?} */ function (period) { /** @type {?} */ var _per = mapUnitOfTime(period); this._date = endOf(this._date, _per, this._isUTC); return this; }; /** * @param {?=} format * @return {?} */ Khronos.prototype.format = /** * @param {?=} format * @return {?} */ function (format) { return formatDate(this._date, format, this._locale && this._locale._abbr, this._isUTC, this._offset); }; // todo: implement // todo: implement /** * @param {?=} time * @param {?=} withoutSuffix * @return {?} */ Khronos.prototype.from = // todo: implement /** * @param {?=} time * @param {?=} withoutSuffix * @return {?} */ function (time, withoutSuffix) { /** @type {?} */ var _time = _moment(time); if (this.isValid() && _time.isValid()) { return createDuration({ to: this.toDate(), from: _time.toDate() }) .locale(this.locale()) .humanize(!withoutSuffix); } return this.localeData().invalidDate; }; /** * @param {?=} withoutSuffix * @return {?} */ Khronos.prototype.fromNow = /** * @param {?=} withoutSuffix * @return {?} */ function (withoutSuffix) { return this.from(new Date(), withoutSuffix); }; /** * @param {?} inp * @param {?=} suffix * @return {?} */ Khronos.prototype.to = /** * @param {?} inp * @param {?=} suffix * @return {?} */ function (inp, suffix) { throw new Error("TODO: Implement"); }; /** * @param {?=} withoutPrefix * @return {?} */ Khronos.prototype.toNow = /** * @param {?=} withoutPrefix * @return {?} */ function (withoutPrefix) { throw new Error("TODO: Implement"); }; /** * @param {?} val * @param {?=} period * @return {?} */ Khronos.prototype.subtract = /** * @param {?} val * @param {?=} period * @return {?} */ function (val, period) { var _this = this; if (isString(val)) { this._date = subtract(this._date, parseInt(val, 10), mapUnitOfTime(period)); return this; } if (isNumber(val)) { this._date = subtract(this._date, val, mapUnitOfTime(period)); } if (isObject(val)) { /** @type {?} */ var _mapped_2 = mapMomentInputObject(val); Object.keys(_mapped_2) .forEach(function (key) { return subtract(_this._date, _mapped_2[key], key); }); } return this; }; /** * @param {?} period * @return {?} */ Khronos.prototype.get = /** * @param {?} period * @return {?} */ function (period) { if (period === 'dayOfYear') { return this.dayOfYear(); } /** @type {?} */ var unit = mapUnitOfTime(period); switch (unit) { case 'year': return this.year(); case 'month': return this.month(); // | 'week' case 'date': return this.date(); case 'day': return this.day(); case 'hours': return this.hours(); case 'minutes': return this.minutes(); case 'seconds': return this.seconds(); case 'milliseconds': return this.milliseconds(); case 'week': return this.week(); case 'isoWeek': return this.isoWeek(); case 'weekYear': return this.weekYear(); case 'isoWeekYear': return this.isoWeekYear(); case 'weekday': return this.weekday(); case 'isoWeekday': return this.isoWeekday(); case 'quarter': return this.quarter(); default: throw new Error("Unknown moment.get('" + period + "')"); } }; /** * @param {?} period * @param {?=} input * @return {?} */ Khronos.prototype.set = /** * @param {?} period * @param {?=} input * @return {?} */ function (period, input) { var _this = this; if (isString(period)) { /** @type {?} */ var unit = mapUnitOfTime(period); switch (unit) { case 'year': return this.year(input); case 'month': return this.month(input); // | 'week' case 'day': return this.day(input); case 'date': return this.date(input); case 'hours': return this.hours(input); case 'minutes': return this.minutes(input); case 'seconds': return this.seconds(input); case 'milliseconds': return this.milliseconds(input); case 'week': return this.week(input); case 'isoWeek': return this.isoWeek(input); case 'weekYear': return this.weekYear(input); case 'isoWeekYear': return this.isoWeekYear(input); case 'weekday': return this.weekday(input); case 'isoWeekday': return this.isoWeekday(input); case 'quarter': return this.quarter(input); default: throw new Error("Unknown moment.get('" + period + "')"); } } if (isObject(period)) { /** @type {?} */ var _mapped_3 = mapMomentInputObject(period); Object.keys(_mapped_3) .sort(function (a, b) { return _unitsPriority[a] - _unitsPriority[b]; }) .forEach(function (key) { return _this.set(key, _mapped_3[key]); }); } return this; }; /** * @return {?} */ Khronos.prototype.toString = /** * @return {?} */ function () { return this.format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ'); }; /** * @return {?} */ Khronos.prototype.toISOString = /** * @return {?} */ function () { if (!this.isValid()) { return null; } if (getFullYear(this._date, true) < 0 || getFullYear(this._date, true) > 9999) { return this.format('YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); } if (isFunction(Date.prototype.toISOString)) { // native implementation is ~50x faster, use it when we can return this.toDate().toISOString(); } return this.format('YYYY-MM-DD[T]HH:mm:ss.SSS[Z]'); }; /** * @return {?} */ Khronos.prototype.inspect = /** * @return {?} */ function () { throw new Error('TODO: implement'); }; /** * @return {?} */ Khronos.prototype.toJSON = /** * @return {?} */ function () { return this.toISOString(); }; /** * @return {?} */ Khronos.prototype.toDate = /** * @return {?} */ function () { return new Date(this.valueOf()); }; /** * @return {?} */ Khronos.prototype.toObject = /** * @return {?} */ function () { return { // years: getFullYear(this._date, this._isUTC), // months: getMonth(this._date, this._isUTC), year: getFullYear(this._date, this._isUTC), month: getMonth(this._date, this._isUTC), date: getDate(this._date, this._isUTC), hours: getHours(this._date, this._isUTC), minutes: getMinutes(this._date, this._isUTC), seconds: getSeconds(this._date, this._isUTC), milliseconds: getMilliseconds(this._date, this._isUTC) }; }; /** * @return {?} */ Khronos.prototype.toArray = /** * @return {?} */ function () { return [this.year(), this.month(), this.date(), this.hour(), this.minute(), this.second(), this.millisecond()]; }; // Dates boolean algebra // Dates boolean algebra /** * @param {?} date * @param {?=} unit * @return {?} */ Khronos.prototype.isAfter = // Dates boolean algebra /** * @param {?} date * @param {?=} unit * @return {?} */ function (date, unit) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isAfter(this._date, date.toDate(), _unit); }; /** * @param {?} date * @param {?=} unit * @return {?} */ Khronos.prototype.isBefore = /** * @param {?} date * @param {?=} unit * @return {?} */ function (date, unit) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isBefore(this.toDate(), date.toDate(), _unit); }; /** * @param {?} from * @param {?} to * @param {?=} unit * @param {?=} inclusivity * @return {?} */ Khronos.prototype.isBetween = /** * @param {?} from * @param {?} to * @param {?=} unit * @param {?=} inclusivity * @return {?} */ function (from, to, unit, inclusivity) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isBetween(this.toDate(), from.toDate(), to.toDate(), _unit, inclusivity); }; /** * @param {?} date * @param {?=} unit * @return {?} */ Khronos.prototype.isSame = /** * @param {?} date * @param {?=} unit * @return {?} */ function (date, unit) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isSame(this._date, date.toDate(), _unit); }; /** * @param {?} date * @param {?=} unit * @return {?} */ Khronos.prototype.isSameOrAfter = /** * @param {?} date * @param {?=} unit * @return {?} */ function (date, unit) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isSameOrAfter(this._date, date.toDate(), _unit); }; /** * @param {?} date * @param {?=} unit * @return {?} */ Khronos.prototype.isSameOrBefore = /** * @param {?} date * @param {?=} unit * @return {?} */ function (date, unit) { /** @type {?} */ var _unit = unit ? mapUnitOfTime(unit) : void 0; return isSameOrBefore(this._date, date.toDate(), _unit); }; /** * @return {?} */ Khronos.prototype.isValid = /** * @return {?} */ function () { return isDateValid(this._date); }; /** * @return {?} */ Khronos.prototype.valueOf = /** * @return {?} */ function () { return this._date.valueOf() - ((this._offset || 0) * 60000); }; /** * @return {?} */ Khronos.prototype.unix = /** * @return {?} */ function () { // return getUnixTime(this._date); return Math.floor(this.valueOf() / 1000); }; /** * @param {?=} b * @param {?=} keepLocalTime * @return {?} */ Khronos.prototype.utcOffset = /** * @param {?=} b * @param {?=} keepLocalTime * @return {?} */ function (b, keepLocalTime) { /** @type {?} */ var _config = this._toConfig(); if (!b && b !== 0) { return getUTCOffset(this._date, _config); } this._date = setUTCOffset(this._date, b, keepLocalTime, false, _config); this._offset = _config._offset; this._isUTC = _config._isUTC; return this; }; /** * @param {?=} keepLocalTime * @return {?} */ Khronos.prototype.utc = /** * @param {?=} keepLocalTime * @return {?} */ function (keepLocalTime) { return this.utcOffset(0, keepLocalTime); }; /** * @param {?=} keepLocalTime * @return {?} */ Khronos.prototype.local = /** * @param {?=} keepLocalTime * @return {?} */ function (keepLocalTime) { if (this._isUTC) { this.utcOffset(0, keepLocalTime); this._isUTC = false; if (keepLocalTime) { this.subtract(getDateOffset(this._date), 'm'); } } return this; }; /** * @param {?=} input * @return {?} */ Khronos.prototype.parseZone = /** * @param {?=} input * @return {?} */ function (input) { /** @type {?} */ var _config = this._toConfig(); this._date = setOffsetToParsedOffset(this._date, input, _config); this._offset = _config._offset; this._isUTC = _config._isUTC; return this; }; /** * @param {?=} input * @return {?} */ Khronos.prototype.hasAlignedHourOffset = /** * @param {?=} input * @return {?} */ function (input) { return hasAlignedHourOffset(this._date, input ? input._date : void 0); }; /** * @return {?} */ Khronos.prototype.isDST = /** * @return {?} */ function () { return isDaylightSavingTime(this._date); }; /** * @return {?} */ Khronos.prototype.isLocal = /** * @return {?} */ function () { return !this._isUTC; }; /** * @return {?} */ Khronos.prototype.isUtcOffset = /** * @return {?} */ function () { return this._isUTC; }; /** * @return {?} */ Khronos.prototype.isUTC = /** * @return {?} */ function () { return this.isUtc(); }; /** * @return {?} */ Khronos.prototype.isUtc = /** * @return {?} */ function () { return this._isUTC && this._offset === 0; }; // Timezone // Timezone /** * @return {?} */ Khronos.prototype.zoneAbbr = // Timezone /** * @return {?} */ function () { return getZoneAbbr(this._isUTC); }; /** * @return {?} */ Khronos.prototype.zoneName = /** * @return {?} */ function () { return getZoneName(this._isUTC); }; /** * @param {?=} year * @return {?} */ Khronos.prototype.year = /** * @param {?=} year * @return {?} */ function (year) { if (!year && year !== 0) { return getFullYear(this._date, this._isUTC); } this._date = cloneDate(setFullYear(this._date, year)); return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.weekYear = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getWeekYear(this._date, this._locale, this.isUTC()); } /** @type {?} */ var date = getSetWeekYear(this._date, val, this._locale, this.isUTC()); if (isDate(date)) { this._date = date; } return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.isoWeekYear = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getISOWeekYear(this._date, this.isUTC()); } /** @type {?} */ var date = getSetISOWeekYear(this._date, val, this.isUtc()); if (isDate(date)) { this._date = date; } return this; }; /** * @return {?} */ Khronos.prototype.isLeapYear = /** * @return {?} */ function () { return isLeapYear(getFullYear(this.toDate(), this.isUTC())); }; /** * @param {?=} month * @return {?} */ Khronos.prototype.month = /** * @param {?=} month * @return {?} */ function (month) { if (!month && month !== 0) { return getMonth(this._date, this._isUTC); } /** @type {?} */ var _month = month; if (isString(month)) { /** @type {?} */ var locale = this._locale || getLocale(); _month = locale.monthsParse(month); } if (isNumber(_month)) { this._date = cloneDate(setMonth(this._date, _month, this._isUTC)); } return this; }; /** * @param {?=} hours * @return {?} */ Khronos.prototype.hour = /** * @param {?=} hours * @return {?} */ function (hours) { return this.hours(hours); }; /** * @param {?=} hours * @return {?} */ Khronos.prototype.hours = /** * @param {?=} hours * @return {?} */ function (hours) { if (!hours && hours !== 0) { return getHours(this._date, this._isUTC); } this._date = cloneDate(setHours(this._date, hours, this._isUTC)); return this; }; /** * @param {?=} minutes * @return {?} */ Khronos.prototype.minute = /** * @param {?=} minutes * @return {?} */ function (minutes) { return this.minutes(minutes); }; /** * @param {?=} minutes * @return {?} */ Khronos.prototype.minutes = /** * @param {?=} minutes * @return {?} */ function (minutes) { if (!minutes && minutes !== 0) { return getMinutes(this._date, this._isUTC); } this._date = cloneDate(setMinutes(this._date, minutes, this._isUTC)); return this; }; /** * @param {?=} seconds * @return {?} */ Khronos.prototype.second = /** * @param {?=} seconds * @return {?} */ function (seconds) { return this.seconds(seconds); }; /** * @param {?=} seconds * @return {?} */ Khronos.prototype.seconds = /** * @param {?=} seconds * @return {?} */ function (seconds) { if (!seconds && seconds !== 0) { return getSeconds(this._date, this._isUTC); } this._date = cloneDate(setSeconds(this._date, seconds, this._isUTC)); return this; }; /** * @param {?=} ms * @return {?} */ Khronos.prototype.millisecond = /** * @param {?=} ms * @return {?} */ function (ms) { return this.milliseconds(ms); }; /** * @param {?=} seconds * @return {?} */ Khronos.prototype.milliseconds = /** * @param {?=} seconds * @return {?} */ function (seconds) { if (!seconds && seconds !== 0) { return getMilliseconds(this._date, this._isUTC); } this._date = cloneDate(setMilliseconds(this._date, seconds, this._isUTC)); return this; }; /** * @param {?=} date * @return {?} */ Khronos.prototype.date = /** * @param {?=} date * @return {?} */ function (date) { if (!date && date !== 0) { return getDate(this._date, this._isUTC); } this._date = cloneDate(setDate(this._date, date, this._isUTC)); return this; }; /** * @param {?=} input * @return {?} */ Khronos.prototype.day = /** * @param {?=} input * @return {?} */ function (input) { if (!input && input !== 0) { return getDayOfWeek(this._date, this._isUTC); } /** @type {?} */ var _input = input; if (isString(input)) { _input = parseWeekday(input, this._locale); } if (isNumber(_input)) { this._date = setDayOfWeek(this._date, _input, this._locale, this._isUTC); } return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.weekday = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getLocaleDayOfWeek(this._date, this._locale, this._isUTC); } this._date = setLocaleDayOfWeek(this._date, val, { locale: this._locale, isUTC: this._isUTC }); return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.isoWeekday = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getISODayOfWeek(this._date); } this._date = setISODayOfWeek(this._date, val); return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.dayOfYear = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getDayOfYear(this._date); } this._date = setDayOfYear(this._date, val); return this; }; /** * @param {?=} input * @return {?} */ Khronos.prototype.week = /** * @param {?=} input * @return {?} */ function (input) { if (!input && input !== 0) { return getWeek(this._date, this._locale); } this._date = setWeek(this._date, input, this._locale); return this; }; /** * @param {?=} input * @return {?} */ Khronos.prototype.weeks = /** * @param {?=} input * @return {?} */ function (input) { return this.week(input); }; /** * @param {?=} val * @return {?} */ Khronos.prototype.isoWeek = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getISOWeek(this._date); } this._date = setISOWeek(this._date, val); return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.isoWeeks = /** * @param {?=} val * @return {?} */ function (val) { return this.isoWeek(val); }; /** * @return {?} */ Khronos.prototype.weeksInYear = /** * @return {?} */ function () { return getWeeksInYear(this._date, this._isUTC, this._locale); }; /** * @return {?} */ Khronos.prototype.isoWeeksInYear = /** * @return {?} */ function () { return getISOWeeksInYear(this._date, this._isUTC); }; /** * @return {?} */ Khronos.prototype.daysInMonth = /** * @return {?} */ function () { return daysInMonth(getFullYear(this._date, this._isUTC), getMonth(this._date, this._isUTC)); }; /** * @param {?=} val * @return {?} */ Khronos.prototype.quarter = /** * @param {?=} val * @return {?} */ function (val) { if (!val && val !== 0) { return getQuarter(this._date, this._isUTC); } this._date = setQuarter(this._date, val, this._isUTC); return this; }; /** * @param {?=} val * @return {?} */ Khronos.prototype.quarters = /** * @param {?=} val * @return {?} */ function (val) { return this.quarter(val); }; /** * @param {?=} period * @return {?} */ Khronos.prototype.startOf = /** * @param {?=} period * @return {?} */ function (period) { /** @type {?} */ var _per = mapUnitOfTime(period); this._date = startOf(this._date, _per, this._isUTC); return this; }; return Khronos; }()); export { Khronos }; if (false) { /** @type {?} */ Khronos.prototype._date; /** @type {?} */ Khronos.prototype._isUTC; /** @type {?} */ Khronos.prototype._isStrict; /** @type {?} */ Khronos.prototype._locale; /** @type {?} */ Khronos.prototype._format; /** @type {?} */ Khronos.prototype._offset; /** @type {?} */ Khronos.prototype._tzm; } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhaW4uanMiLCJzb3VyY2VSb290Ijoibmc6Ly9uZ3gtYm9vdHN0cmFwL2Nocm9ub3MvIiwic291cmNlcyI6WyJ0ZXN0L2NoYWluLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUNBLE9BQU8sRUFBRSxHQUFHLEVBQWEsUUFBUSxFQUFFLE1BQU0sVUFBVSxDQUFDO0FBRXBELE9BQU8sRUFDTCxPQUFPLEVBQUUsV0FBVyxFQUFFLFFBQVEsRUFBRS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