UNPKG

ng-zorro-antd

Version:

An enterprise-class UI components based on Ant Design and Angular

255 lines 30.5 kB
/** * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://github.com/NG-ZORRO/ng-zorro-antd/blob/master/LICENSE */ import { addMonths, addYears, differenceInCalendarDays, differenceInCalendarMonths, differenceInCalendarYears, differenceInHours, differenceInMinutes, differenceInSeconds, isFirstDayOfMonth, isLastDayOfMonth, isSameDay, isSameHour, isSameMinute, isSameMonth, isSameSecond, isSameYear, isToday, isValid, setDay, setMonth, setYear, startOfMonth, startOfWeek } from 'date-fns'; import { warn } from 'ng-zorro-antd/core/logger'; export function wrongSortOrder(rangeValue) { const [start, end] = rangeValue; return !!start && !!end && end.isBeforeDay(start); } export function normalizeRangeValue(value, hasTimePicker, type = 'month', activePart = 'left') { const [start, end] = value; let newStart = start || new CandyDate(); let newEnd = end || (hasTimePicker ? newStart : newStart.add(1, type)); if (start && !end) { newStart = start; newEnd = hasTimePicker ? start : start.add(1, type); } else if (!start && end) { newStart = hasTimePicker ? end : end.add(-1, type); newEnd = end; } else if (start && end && !hasTimePicker) { if (start.isSame(end, type)) { newEnd = newStart.add(1, type); } else { if (activePart === 'left') { newEnd = newStart.add(1, type); } else { newStart = newEnd.add(-1, type); } } } return [newStart, newEnd]; } export function cloneDate(value) { if (Array.isArray(value)) { return value.map(v => (v instanceof CandyDate ? v.clone() : null)); } else { return value instanceof CandyDate ? value.clone() : null; } } /** * Wrapping kind APIs for date operating and unify * NOTE: every new API return new CandyDate object without side effects to the former Date object * NOTE: most APIs are based on local time other than customized locale id (this needs tobe support in future) * TODO: support format() against to angular's core API */ export class CandyDate { // locale: string; // Custom specified locale ID constructor(date) { if (date) { if (date instanceof Date) { this.nativeDate = date; } else if (typeof date === 'string' || typeof date === 'number') { warn('The string type is not recommended for date-picker, use "Date" type'); this.nativeDate = new Date(date); } else { throw new Error('The input date type is not supported ("Date" is now recommended)'); } } else { this.nativeDate = new Date(); } } calendarStart(options) { return new CandyDate(startOfWeek(startOfMonth(this.nativeDate), options)); } // --------------------------------------------------------------------- // | Native shortcuts // -----------------------------------------------------------------------------\ getYear() { return this.nativeDate.getFullYear(); } getMonth() { return this.nativeDate.getMonth(); } getDay() { return this.nativeDate.getDay(); } getTime() { return this.nativeDate.getTime(); } getDate() { return this.nativeDate.getDate(); } getHours() { return this.nativeDate.getHours(); } getMinutes() { return this.nativeDate.getMinutes(); } getSeconds() { return this.nativeDate.getSeconds(); } getMilliseconds() { return this.nativeDate.getMilliseconds(); } // --------------------------------------------------------------------- // | New implementing APIs // --------------------------------------------------------------------- clone() { return new CandyDate(new Date(this.nativeDate)); } setHms(hour, minute, second) { const newDate = new Date(this.nativeDate.setHours(hour, minute, second)); return new CandyDate(newDate); } setYear(year) { return new CandyDate(setYear(this.nativeDate, year)); } addYears(amount) { return new CandyDate(addYears(this.nativeDate, amount)); } // NOTE: month starts from 0 // NOTE: Don't use the native API for month manipulation as it not restrict the date when it overflows, eg. (new Date('2018-7-31')).setMonth(1) will be date of 2018-3-03 instead of 2018-2-28 setMonth(month) { return new CandyDate(setMonth(this.nativeDate, month)); } addMonths(amount) { return new CandyDate(addMonths(this.nativeDate, amount)); } setDay(day, options) { return new CandyDate(setDay(this.nativeDate, day, options)); } setDate(amount) { const date = new Date(this.nativeDate); date.setDate(amount); return new CandyDate(date); } addDays(amount) { return this.setDate(this.getDate() + amount); } add(amount, mode) { switch (mode) { case 'decade': return this.addYears(amount * 10); case 'year': return this.addYears(amount); case 'month': return this.addMonths(amount); default: return this.addMonths(amount); } } isSame(date, grain = 'day') { let fn; switch (grain) { case 'decade': fn = (pre, next) => Math.abs(pre.getFullYear() - next.getFullYear()) < 11; break; case 'year': fn = isSameYear; break; case 'month': fn = isSameMonth; break; case 'day': fn = isSameDay; break; case 'hour': fn = isSameHour; break; case 'minute': fn = isSameMinute; break; case 'second': fn = isSameSecond; break; default: fn = isSameDay; break; } return fn(this.nativeDate, this.toNativeDate(date)); } isSameYear(date) { return this.isSame(date, 'year'); } isSameMonth(date) { return this.isSame(date, 'month'); } isSameDay(date) { return this.isSame(date, 'day'); } isSameHour(date) { return this.isSame(date, 'hour'); } isSameMinute(date) { return this.isSame(date, 'minute'); } isSameSecond(date) { return this.isSame(date, 'second'); } isBefore(date, grain = 'day') { if (date === null) { return false; } let fn; switch (grain) { case 'year': fn = differenceInCalendarYears; break; case 'month': fn = differenceInCalendarMonths; break; case 'day': fn = differenceInCalendarDays; break; case 'hour': fn = differenceInHours; break; case 'minute': fn = differenceInMinutes; break; case 'second': fn = differenceInSeconds; break; default: fn = differenceInCalendarDays; break; } return fn(this.nativeDate, this.toNativeDate(date)) < 0; } isBeforeYear(date) { return this.isBefore(date, 'year'); } isBeforeMonth(date) { return this.isBefore(date, 'month'); } isBeforeDay(date) { return this.isBefore(date, 'day'); } // Equal to today accurate to "day" isToday() { return isToday(this.nativeDate); } isValid() { return isValid(this.nativeDate); } isFirstDayOfMonth() { return isFirstDayOfMonth(this.nativeDate); } isLastDayOfMonth() { return isLastDayOfMonth(this.nativeDate); } toNativeDate(date) { return date instanceof CandyDate ? date.nativeDate : date; } } //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FuZHktZGF0ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL2NvbXBvbmVudHMvY29yZS90aW1lL2NhbmR5LWRhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7OztHQUdHO0FBRUgsT0FBTyxFQUNMLFNBQVMsRUFDVCxRQUFRLEVBQ1Isd0JBQXdCLEVBQ3hCLDBCQUEwQixFQUMxQix5QkFBeUIsRUFDekIsaUJBQWlCLEVBQ2pCLG1CQUFtQixFQUNuQixtQkFBbUIsRUFDbkIsaUJBQWlCLEVBQ2pCLGdCQUFnQixFQUNoQixTQUFTLEVBQ1QsVUFBVSxFQUNWLFlBQVksRUFDWixXQUFXLEVBQ1gsWUFBW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