ng-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
16 lines (14 loc) • 8.95 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("date-fns"),require("ng-zorro-antd/core/logger"),require("@angular/common"),require("ng-zorro-antd/core/util")):"function"==typeof define&&define.amd?define("ng-zorro-antd/core/time",["exports","date-fns","ng-zorro-antd/core/logger","@angular/common","ng-zorro-antd/core/util"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self)["ng-zorro-antd"]=e["ng-zorro-antd"]||{},e["ng-zorro-antd"].core=e["ng-zorro-antd"].core||{},e["ng-zorro-antd"].core.time={}),e.dateFns,e["ng-zorro-antd"].core.logger,e.ng.common,e["ng-zorro-antd"].core.util)}(this,(function(e,t,r,n,a){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */Object.create;function o(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,o=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i}Object.create;var i=function(){function e(e){if(e)if(e instanceof Date)this.nativeDate=e;else{if("string"!=typeof e&&"number"!=typeof e)throw new Error('The input date type is not supported ("Date" is now recommended)');r.warn('The string type is not recommended for date-picker, use "Date" type'),this.nativeDate=new Date(e)}else this.nativeDate=new Date}return e.prototype.calendarStart=function(r){return new e(t.startOfWeek(t.startOfMonth(this.nativeDate),r))},e.prototype.getYear=function(){return this.nativeDate.getFullYear()},e.prototype.getMonth=function(){return this.nativeDate.getMonth()},e.prototype.getDay=function(){return this.nativeDate.getDay()},e.prototype.getTime=function(){return this.nativeDate.getTime()},e.prototype.getDate=function(){return this.nativeDate.getDate()},e.prototype.getHours=function(){return this.nativeDate.getHours()},e.prototype.getMinutes=function(){return this.nativeDate.getMinutes()},e.prototype.getSeconds=function(){return this.nativeDate.getSeconds()},e.prototype.getMilliseconds=function(){return this.nativeDate.getMilliseconds()},e.prototype.clone=function(){return new e(new Date(this.nativeDate))},e.prototype.setHms=function(t,r,n){return new e(new Date(this.nativeDate.setHours(t,r,n)))},e.prototype.setYear=function(r){return new e(t.setYear(this.nativeDate,r))},e.prototype.addYears=function(r){return new e(t.addYears(this.nativeDate,r))},e.prototype.setMonth=function(r){return new e(t.setMonth(this.nativeDate,r))},e.prototype.addMonths=function(r){return new e(t.addMonths(this.nativeDate,r))},e.prototype.setDay=function(r,n){return new e(t.setDay(this.nativeDate,r,n))},e.prototype.setDate=function(t){var r=new Date(this.nativeDate);return r.setDate(t),new e(r)},e.prototype.addDays=function(e){return this.setDate(this.getDate()+e)},e.prototype.add=function(e,t){switch(t){case"decade":return this.addYears(10*e);case"year":return this.addYears(e);case"month":default:return this.addMonths(e)}},e.prototype.isSame=function(e,r){var n;switch(void 0===r&&(r="day"),r){case"decade":n=function(e,t){return Math.abs(e.getFullYear()-t.getFullYear())<11};break;case"year":n=t.isSameYear;break;case"month":n=t.isSameMonth;break;case"day":n=t.isSameDay;break;case"hour":n=t.isSameHour;break;case"minute":n=t.isSameMinute;break;case"second":n=t.isSameSecond;break;default:n=t.isSameDay}return n(this.nativeDate,this.toNativeDate(e))},e.prototype.isSameYear=function(e){return this.isSame(e,"year")},e.prototype.isSameMonth=function(e){return this.isSame(e,"month")},e.prototype.isSameDay=function(e){return this.isSame(e,"day")},e.prototype.isSameHour=function(e){return this.isSame(e,"hour")},e.prototype.isSameMinute=function(e){return this.isSame(e,"minute")},e.prototype.isSameSecond=function(e){return this.isSame(e,"second")},e.prototype.isBefore=function(e,r){if(void 0===r&&(r="day"),null===e)return!1;var n;switch(r){case"year":n=t.differenceInCalendarYears;break;case"month":n=t.differenceInCalendarMonths;break;case"day":n=t.differenceInCalendarDays;break;case"hour":n=t.differenceInHours;break;case"minute":n=t.differenceInMinutes;break;case"second":n=t.differenceInSeconds;break;default:n=t.differenceInCalendarDays}return n(this.nativeDate,this.toNativeDate(e))<0},e.prototype.isBeforeYear=function(e){return this.isBefore(e,"year")},e.prototype.isBeforeMonth=function(e){return this.isBefore(e,"month")},e.prototype.isBeforeDay=function(e){return this.isBefore(e,"day")},e.prototype.isToday=function(){return t.isToday(this.nativeDate)},e.prototype.isValid=function(){return t.isValid(this.nativeDate)},e.prototype.isFirstDayOfMonth=function(){return t.isFirstDayOfMonth(this.nativeDate)},e.prototype.isLastDayOfMonth=function(){return t.isLastDayOfMonth(this.nativeDate)},e.prototype.toNativeDate=function(t){return t instanceof e?t.nativeDate:t},e}(),s=function(){function e(e,t){this.format=e,this.localeId=t,this.regex=null,this.matchMap={hour:null,minute:null,second:null,periodNarrow:null,periodWide:null,periodAbbreviated:null},this.genRegexp()}return e.prototype.toDate=function(e){var t=this.getTimeResult(e),r=new Date;return a.isNotNil(null==t?void 0:t.hour)&&r.setHours(t.hour),a.isNotNil(null==t?void 0:t.minute)&&r.setMinutes(t.minute),a.isNotNil(null==t?void 0:t.second)&&r.setSeconds(t.second),1===(null==t?void 0:t.period)&&r.getHours()<12&&r.setHours(r.getHours()+12),r},e.prototype.getTimeResult=function(e){var t=this.regex.exec(e),r=null;return t?(a.isNotNil(this.matchMap.periodNarrow)&&(r=n.getLocaleDayPeriods(this.localeId,n.FormStyle.Format,n.TranslationWidth.Narrow).indexOf(t[this.matchMap.periodNarrow+1])),a.isNotNil(this.matchMap.periodWide)&&(r=n.getLocaleDayPeriods(this.localeId,n.FormStyle.Format,n.TranslationWidth.Wide).indexOf(t[this.matchMap.periodWide+1])),a.isNotNil(this.matchMap.periodAbbreviated)&&(r=n.getLocaleDayPeriods(this.localeId,n.FormStyle.Format,n.TranslationWidth.Abbreviated).indexOf(t[this.matchMap.periodAbbreviated+1])),{hour:a.isNotNil(this.matchMap.hour)?Number.parseInt(t[this.matchMap.hour+1],10):null,minute:a.isNotNil(this.matchMap.minute)?Number.parseInt(t[this.matchMap.minute+1],10):null,second:a.isNotNil(this.matchMap.second)?Number.parseInt(t[this.matchMap.second+1],10):null,period:r}):null},e.prototype.genRegexp=function(){var e=this,t=this.format.replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$&"),r=/h{1,2}/i,a=/m{1,2}/,o=/s{1,2}/,i=/aaaaa/,s=/aaaa/,u=/a{1,3}/,c=r.exec(this.format),d=a.exec(this.format),l=o.exec(this.format),h=i.exec(this.format),p=null,f=null;h||(p=s.exec(this.format)),p||h||(f=u.exec(this.format)),[c,d,l,h,p,f].filter((function(e){return!!e})).sort((function(e,t){return e.index-t.index})).forEach((function(m,y){switch(m){case c:e.matchMap.hour=y,t=t.replace(r,"(\\d{1,2})");break;case d:e.matchMap.minute=y,t=t.replace(a,"(\\d{1,2})");break;case l:e.matchMap.second=y,t=t.replace(o,"(\\d{1,2})");break;case h:e.matchMap.periodNarrow=y;var D=n.getLocaleDayPeriods(e.localeId,n.FormStyle.Format,n.TranslationWidth.Narrow).join("|");t=t.replace(i,"("+D+")");break;case p:e.matchMap.periodWide=y;var g=n.getLocaleDayPeriods(e.localeId,n.FormStyle.Format,n.TranslationWidth.Wide).join("|");t=t.replace(s,"("+g+")");break;case f:e.matchMap.periodAbbreviated=y;var v=n.getLocaleDayPeriods(e.localeId,n.FormStyle.Format,n.TranslationWidth.Abbreviated).join("|");t=t.replace(u,"("+v+")")}})),this.regex=new RegExp(t)},e}();e.CandyDate=i,e.cloneDate=function(e){return Array.isArray(e)?e.map((function(e){return e instanceof i?e.clone():null})):e instanceof i?e.clone():null},e.normalizeRangeValue=function(e,t,r,n){void 0===r&&(r="month"),void 0===n&&(n="left");var a=o(e,2),s=a[0],u=a[1],c=s||new i,d=u||(t?c:c.add(1,r));return s&&!u?(c=s,d=t?s:s.add(1,r)):!s&&u?(c=t?u:u.add(-1,r),d=u):s&&u&&!t&&(s.isSame(u,r)||"left"===n?d=c.add(1,r):c=d.add(-1,r)),[c,d]},e.timeUnits=[["Y",31536e6],["M",2592e6],["D",864e5],["H",36e5],["m",6e4],["s",1e3],["S",1]],e.wrongSortOrder=function(e){var t=o(e,2),r=t[0],n=t[1];return!!r&&!!n&&n.isBeforeDay(r)},e.ɵNgTimeParser=s,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=ng-zorro-antd-core-time.umd.min.js.map