Comparing version 3.0.1 to 3.0.5
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -226,19 +226,41 @@ * Released under the MIT License. | ||
var dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
var day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
var UNITS = {}; | ||
var setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
var fns = {}; | ||
function normalizeUnit (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
var longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[("get" + method)](); | ||
} else { | ||
date[("set" + method)](val); | ||
return date; | ||
} | ||
}; | ||
}setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
var indexOfUnits = { | ||
@@ -255,3 +277,3 @@ Y: 0, | ||
function getIndex(units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
return indexOfUnits[units]; | ||
@@ -569,3 +591,3 @@ } | ||
var output; | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
@@ -600,3 +622,3 @@ switch (units) { | ||
function startOf (date, units) { | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
switch (units) { | ||
@@ -627,3 +649,3 @@ case 'Y': | ||
function endOf (date, units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -711,5 +733,10 @@ return date; | ||
function get (date, unit) { | ||
unit = normalize(unit, 't'); | ||
return fns[unit](date); | ||
} | ||
function compare (date, input, units, type) { | ||
input = parse(input); | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -767,2 +794,8 @@ switch (type) { | ||
function set (date, unit, val) { | ||
unit = normalize(unit); | ||
unit && fns[unit](date, val); | ||
return date; | ||
} | ||
function subtract (date, num, unit) { | ||
@@ -780,2 +813,3 @@ return add(date, -num, unit); | ||
format: format, | ||
get: get, | ||
isAfter: isAfter, | ||
@@ -790,2 +824,3 @@ isBefore: isBefore, | ||
parse: parse, | ||
set: set, | ||
startOf: startOf, | ||
@@ -792,0 +827,0 @@ subtract: subtract |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -224,19 +224,41 @@ * Released under the MIT License. | ||
var dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
var day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
var UNITS = {}; | ||
var setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
var fns = {}; | ||
function normalizeUnit (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
var longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[("get" + method)](); | ||
} else { | ||
date[("set" + method)](val); | ||
return date; | ||
} | ||
}; | ||
}setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
var indexOfUnits = { | ||
@@ -253,3 +275,3 @@ Y: 0, | ||
function getIndex(units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
return indexOfUnits[units]; | ||
@@ -567,3 +589,3 @@ } | ||
var output; | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
@@ -598,3 +620,3 @@ switch (units) { | ||
function startOf (date, units) { | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
switch (units) { | ||
@@ -625,3 +647,3 @@ case 'Y': | ||
function endOf (date, units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -709,5 +731,10 @@ return date; | ||
function get (date, unit) { | ||
unit = normalize(unit, 't'); | ||
return fns[unit](date); | ||
} | ||
function compare (date, input, units, type) { | ||
input = parse(input); | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -765,2 +792,8 @@ switch (type) { | ||
function set (date, unit, val) { | ||
unit = normalize(unit); | ||
unit && fns[unit](date, val); | ||
return date; | ||
} | ||
function subtract (date, num, unit) { | ||
@@ -778,2 +811,3 @@ return add(date, -num, unit); | ||
format: format, | ||
get: get, | ||
isAfter: isAfter, | ||
@@ -788,2 +822,3 @@ isBefore: isBefore, | ||
parse: parse, | ||
set: set, | ||
startOf: startOf, | ||
@@ -790,0 +825,0 @@ subtract: subtract |
71
celia.js
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -230,19 +230,41 @@ * Released under the MIT License. | ||
var dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
var day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
var UNITS = {}; | ||
var setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
var fns = {}; | ||
function normalizeUnit (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
var longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[("get" + method)](); | ||
} else { | ||
date[("set" + method)](val); | ||
return date; | ||
} | ||
}; | ||
}setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
var indexOfUnits = { | ||
@@ -259,3 +281,3 @@ Y: 0, | ||
function getIndex(units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
return indexOfUnits[units]; | ||
@@ -573,3 +595,3 @@ } | ||
var output; | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
@@ -604,3 +626,3 @@ switch (units) { | ||
function startOf (date, units) { | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
switch (units) { | ||
@@ -631,3 +653,3 @@ case 'Y': | ||
function endOf (date, units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -715,5 +737,10 @@ return date; | ||
function get (date, unit) { | ||
unit = normalize(unit, 't'); | ||
return fns[unit](date); | ||
} | ||
function compare (date, input, units, type) { | ||
input = parse(input); | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -771,2 +798,8 @@ switch (type) { | ||
function set (date, unit, val) { | ||
unit = normalize(unit); | ||
unit && fns[unit](date, val); | ||
return date; | ||
} | ||
function subtract (date, num, unit) { | ||
@@ -784,2 +817,3 @@ return add(date, -num, unit); | ||
format: format, | ||
get: get, | ||
isAfter: isAfter, | ||
@@ -794,2 +828,3 @@ isBefore: isBefore, | ||
parse: parse, | ||
set: set, | ||
startOf: startOf, | ||
@@ -796,0 +831,0 @@ subtract: subtract |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
"use strict";function i(e,n){return n?e.bind(n):e}function c(e,n,t){for(var r=i(n,t),u=0,a=e.length,c=void 0;!1!==c&&u<a;u++)c=r(e[u],u,e)}function a(e,n,t){return e&&c(e,n,t)}function s(e,n){e[e.length]=n}function r(e,n,t){if(n){if(n.indexOf)return n.indexOf(e,t);for(var r=n.length,u=t?t<0?Math.max(0,r+t):t:0;u<r;u++)if(u in n&&n[u]===e)return u}return-1}function u(n,e){var t=n.length;return a(e,function(e){n[t++]=e}),n.length=t,n}function o(e){return null==e}function n(e){return"function"==typeof e}function d(e){return"number"==typeof e}function f(e){return!o(e)&&d(e.length)&&!n(e)}function l(e){return"string"==typeof e}var m=Array.prototype.push;function h(e,n,t){var r=i(n,t);for(var u in e)if(!1===r(e[u],u,e))break}function g(e,n,t){for(var r=i(n,t),u=0,a=void 0;!1!==a&&u<e;u++)a=r(u,u,u)}function v(e,n,t){e&&(f(e)?c(e,n,t):d(e)?g(e,n,t):h(e,n,t))}function Y(e,n){return e.splice(n,1),n}var e={append:function(e,n){if(e)return e[e.length]=n},forEach:a,grep:function(e,t,r){var u=[];return r=!!r,a(e,function(e,n){!t(e,n)===r&&s(u,e)}),u},inArray:r,includes:function(e,n){return-1!==r(n,e)},join:u,makeArray:function(e,n){var t=n||[];return e&&(f(Object(e))?u(t,l(e)?[e]:e):t.push?t.push(e):m.call(t,e)),t},map:function(e,n,t){var r=[],u=i(n,t);return v(e,function(e){o(e=u(e))||s(r,e)}),r},remove:function(e,n){var t=r(n,e);return 0<=t?(Y(e,t),n):null},removeAt:Y,toArray:function(e){return e&&[].concat(e)}},t=/-([a-z])/g;function M(e){return!o(e)&&"object"==typeof e}function S(e,n){return n?new Date(Date.UTC(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var b={},p=function(e,n){b[e]=b[e.slice(0,-1)]=b[n]=n};function D(e,n){return b[e]||n}p("years","Y"),p("months","M"),p("dates","D"),p("days","d"),p("hours","h"),p("minutes","m"),p("seconds","s"),p("milliseconds","ms");var y={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function H(e){return e=D(e,"ms"),y[e]}function w(e,n,t){var r=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(M(n))h(n,function(e,n){var t=H(n);r[t]+=e});else{var u=H(t);r[u]+=n}return e.setTime(+S(r)),e}function k(e){return new Date(+e)}function A(e){var n=e.getFullYear();return n%4==0&&n%100!=0||n%400==0}var O=[31,28,31,30,31,30,31,31,30,31,30,31],x=[31,29,31,30,31,30,31,31,30,31,30,31];function T(e){return A(e)?x:O}function Z(e){return void 0===e}var j=/^\/?Date\((-?\d+)/i,F=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,C=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],I=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,U=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,B=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],E=/(Z)|[+-](\d\d)(?::?(\d\d))?/,L=(new Date).getTimezoneOffset(),N=Object.prototype.toString;function W(e){return N.call(e)}function z(e){return"[object Date]"===W(e)}function P(e,n,t){if(!l(e))return S(e,!0===n);if(l(n))return S(function(t,r){var e,n=r.length,u=[],a=!1;if(g(n,function(e){var n=t.charAt(e);switch(r.charAt(e)){case"Y":case"y":u[0]=(u[0]||"")+n;break;case"M":u[1]=(u[1]||"")+n;break;case"D":case"d":u[2]=(u[2]||"")+n;break;case"H":case"h":u[3]=(u[3]||"")+n;break;case"m":u[4]=(u[4]||"")+n;break;case"s":u[5]=(u[5]||"")+n;break;case"S":u[6]=(u[6]||"")+n;break;case"Z":a=!0}}),u=u.map(function(e){return parseInt(e,10)}),a)if(e=E.exec(t.slice(-1<r.indexOf("ZZ")?-5:-6))){var c=L;if(!e[1]){var i="+"===e[0].charAt(0)?1:-1;u[3]-=e[2]*i,u[4]-=(e[3]||0)*i}u[4]-=c}else u.isUTC=a&-1<t.indexOf("Z");return o(u[1])||(u[1]-=1),u}(e,n),t);var r=function(e){var t,r,u=[],a=I.exec(e)||F.exec(e);if(a){if(c(C,function(e,n){if(r=e[1].exec(a[1]))return g(3,function(e){u[e]=parseInt(r[e+1]||1,10)}),u[1]-=1,t=!1!==e[2],!1}),e.indexOf(u[0]))return e;if(r=null,a[3]&&c(B,function(e){if(r=e[1].exec(a[3]))return u=u.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!t&&r)return u;if(r=null,a[4]){r=E.exec(a[4]);var n=L;r[1]||(u[3]-=r[2],u[4]-=r[3]||0),u[4]-=n}return u}return 4===e.length&&C[4][1].test(e)?((u=[parseInt(e,10),0,1]).isUTC=!0,u):e}(e);if(r!==e)return S(r,r.isUTC||!0===n);var u=j.exec(e);return new Date(null!==u?+u[1]:e)}function V(e,n,t){return e=o(e)?new Date:e.length?P(e,n,t):d(e)?new Date(e):z(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function $(e,n){var t=12*(n.getFullYear()-e.getFullYear())+(n.getMonth()-e.getMonth()),r=w(k(e),t,"months");return-(t+(n<r?(n-r)/(r-w(k(e),t-1,"months")):(n-r)/(w(k(e),t+1,"months")-r)))||0}function R(e,n){switch(n=D(n)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function _(e,n){return"ms"===(n=D(n,"ms"))||(R(e,n),w(e,1,n),w(e,-1,"ms")),e}function q(e,n){return void 0===n&&(n=2),("000000"+e).slice(-n)}function G(e,n){var t;return e<0?(t="+",e=Math.abs(e)):t="-",""+t+q(Math.floor(e/60))+(n?"":":")+q(Math.floor(e%60))}function J(e){return 12<(e=e||24)?e-12:e}function K(e,n,t,r){if(n=V(n),"ms"===(t=D(t,"ms")))switch(r){case"before":return+e<+n;case"after":return+n<+e;default:return+e==+n}else{var u=+n;switch(r){case"before":return+_(k(e),t)<u;case"after":return+R(k(e),t)>u;default:return+R(k(e),t)<=u&&u<=+_(k(e),t)}}}function Q(e,n,t){return K(e,n,t,"after")}function X(e,n,t){return K(e,n,t,"before")}var ee={add:w,clone:k,dayOfYear:function(e,n){var t=T(e),r=e.getMonth(),u=0;return g(r,function(e){u+=t[e]}),u+=e.getDate(),Z(n)?u:(e.setTime(+e+864e5*(n-u)),e)},daysInMonth:function(e){return T(e)[e.getMonth()]},diff:function(e,n,t,r){var u,a;switch(n=V(n),t=D(t)){case"Y":u=$(e,n)/12;break;case"M":u=$(e,n);break;case"s":u=(e-n)/1e3;break;case"m":u=(e-n)/6e4;break;case"h":u=(e-n)/36e5;break;case"d":u=(e-n)/864e5;break;default:u=e-n}return r?u:(a=u)<0?Math.ceil(a)||0:Math.floor(a)},endOf:_,format:function(n,e){return e&&"UTC"!==e?e.replace(U,function(e){switch(e){case"YY":return String(n.getFullYear()).slice(-2);case"YYYY":case"yyyy":return n.getFullYear();case"M":return n.getMonth()+1;case"MM":return q(n.getMonth()+1);case"D":case"d":return n.getDate();case"DD":case"dd":return q(n.getDate());case"H":return n.getHours();case"HH":return q(n.getHours());case"h":return J(n.getHours());case"hh":return q(J(n.getHours()));case"m":return n.getMinutes();case"mm":return q(n.getMinutes());case"s":return n.getSeconds();case"ss":return q(n.getSeconds());case"SSS":return q(n.getMilliseconds(),3);case"Z":return G(L);case"ZZ":return G(L,!0);default:return e}}):n.toISOString()},isAfter:Q,isBefore:X,isBetween:function(e,n,t,r,u){return("("===(u=u||"()").charAt(0)?Q(e,n,r):!X(e,n,r))&&(")"===u.charAt(1)?X(e,t,r):!Q(e,t,r))},isLeapYear:A,isSame:function(e,n,t){return K(e,n,t)},isSameOrAfter:function(e,n,t){return!X(e,n,t)},isSameOrBefore:function(e,n,t){return!Q(e,n,t)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:V,startOf:R,subtract:function(e,n,t){return w(e,-n,t)}};var ne={};"Boolean,Number,String,Function,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(e){ne["[object "+e+"]"]=e.toLowerCase()});var te={array:e,camelCase:function(e){return e.replace(t,function(e,n){return n.toUpperCase()})},date:ee,each:v,forEach:a,forIn:function(e,n,t){return e&&h(e,n,t)},forNumber:function(e,n,t){return e&&g(e,n,t)},isArrayLike:f,isAsyncFunction:function(e){return"[object AsyncFunction]"===W(e)},isBoolean:function(e){return"boolean"==typeof e},isDate:z,isFunction:n,isNil:o,isNumber:d,isObject:M,isPromiseLike:function(e){return!!e&&n(e.then)},isString:l,isUndefined:Z,sleep:function(n){return new Promise(function(e){setTimeout(e,n)})},type:function(e){return o(e)?e+"":M(e)||n(e)?ne[W(e)]||"object":typeof e}};module.exports=te; | ||
"use strict";function s(e,t){return t?e.bind(t):e}function i(e,t,n){for(var r=s(t,n),u=0,a=e.length,i=void 0;!1!==i&&u<a;u++)i=r(e[u],u,e)}function a(e,t,n){return e&&i(e,t,n)}function c(e,t){e[e.length]=t}function r(e,t,n){if(t){if(t.indexOf)return t.indexOf(e,n);for(var r=t.length,u=n?n<0?Math.max(0,r+n):n:0;u<r;u++)if(u in t&&t[u]===e)return u}return-1}function u(t,e){var n=t.length;return a(e,function(e){t[n++]=e}),t.length=n,t}function o(e){return null==e}function t(e){return"function"==typeof e}function d(e){return"number"==typeof e}function f(e){return!o(e)&&d(e.length)&&!t(e)}function l(e){return"string"==typeof e}var m=Array.prototype.push;function h(e,t,n){var r=s(t,n);for(var u in e)if(!1===r(e[u],u,e))break}function g(e,t,n){for(var r=s(t,n),u=0,a=void 0;!1!==a&&u<e;u++)a=r(u,u,u)}function v(e,t,n){e&&(f(e)?i(e,t,n):d(e)?g(e,t,n):h(e,t,n))}function M(e,t){return e.splice(t,1),t}var e={append:function(e,t){if(e)return e[e.length]=t},forEach:a,grep:function(e,n,r){var u=[];return r=!!r,a(e,function(e,t){!n(e,t)===r&&c(u,e)}),u},inArray:r,includes:function(e,t){return-1!==r(t,e)},join:u,makeArray:function(e,t){var n=t||[];return e&&(f(Object(e))?u(n,l(e)?[e]:e):n.push?n.push(e):m.call(n,e)),n},map:function(e,t,n){var r=[],u=s(t,n);return v(e,function(e){o(e=u(e))||c(r,e)}),r},remove:function(e,t){var n=r(t,e);return 0<=n?(M(e,n),t):null},removeAt:M,toArray:function(e){return e&&[].concat(e)}},n=/-([a-z])/g;function Y(e){return!o(e)&&"object"==typeof e}function S(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var D=Date.prototype;D.setDay||(D.setDay=function(e){var t=this.getDay();e!==t&&this.setTime(+this+864e5*(e-t))});var p={},b={};function y(e,t){return p[e]||t}function H(e,t,n){var r=e.slice(0,-1);p[t]=p[e]=p[r]=t,b[t]=function(e,t){return o(t)?e["get"+n]():(e["set"+n](t),e)}}H("years","Y","FullYear"),H("months","M","Month"),H("dates","D","Date"),H("days","d","Day"),H("hours","h","Hours"),H("minutes","m","Minutes"),H("seconds","s","Seconds"),H("milliseconds","ms","Milliseconds"),H("times","t","Time");var w={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function k(e){return e=y(e,"ms"),w[e]}function A(e,t,n){var r=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(Y(t))h(t,function(e,t){var n=k(t);r[n]+=e});else{var u=k(n);r[u]+=t}return e.setTime(+S(r)),e}function O(e){return new Date(+e)}function x(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var T=[31,28,31,30,31,30,31,31,30,31,30,31],F=[31,29,31,30,31,30,31,31,30,31,30,31];function Z(e){return x(e)?F:T}function j(e){return void 0===e}var C=/^\/?Date\((-?\d+)/i,I=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,U=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],B=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,E=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,L=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],N=/(Z)|[+-](\d\d)(?::?(\d\d))?/,W=(new Date).getTimezoneOffset(),z=Object.prototype.toString;function P(e){return z.call(e)}function V(e){return"[object Date]"===P(e)}function $(e,t,n){if(!l(e))return S(e,!0===t);if(l(t))return S(function(n,r){var e,t=r.length,u=[],a=!1;if(g(t,function(e){var t=n.charAt(e);switch(r.charAt(e)){case"Y":case"y":u[0]=(u[0]||"")+t;break;case"M":u[1]=(u[1]||"")+t;break;case"D":case"d":u[2]=(u[2]||"")+t;break;case"H":case"h":u[3]=(u[3]||"")+t;break;case"m":u[4]=(u[4]||"")+t;break;case"s":u[5]=(u[5]||"")+t;break;case"S":u[6]=(u[6]||"")+t;break;case"Z":a=!0}}),u=u.map(function(e){return parseInt(e,10)}),a)if(e=N.exec(n.slice(-1<r.indexOf("ZZ")?-5:-6))){var i=W;if(!e[1]){var s="+"===e[0].charAt(0)?1:-1;u[3]-=e[2]*s,u[4]-=(e[3]||0)*s}u[4]-=i}else u.isUTC=a&-1<n.indexOf("Z");return o(u[1])||(u[1]-=1),u}(e,t),n);var r=function(e){var n,r,u=[],a=B.exec(e)||I.exec(e);if(a){if(i(U,function(e,t){if(r=e[1].exec(a[1]))return g(3,function(e){u[e]=parseInt(r[e+1]||1,10)}),u[1]-=1,n=!1!==e[2],!1}),e.indexOf(u[0]))return e;if(r=null,a[3]&&i(L,function(e){if(r=e[1].exec(a[3]))return u=u.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!n&&r)return u;if(r=null,a[4]){r=N.exec(a[4]);var t=W;r[1]||(u[3]-=r[2],u[4]-=r[3]||0),u[4]-=t}return u}return 4===e.length&&U[4][1].test(e)?((u=[parseInt(e,10),0,1]).isUTC=!0,u):e}(e);if(r!==e)return S(r,r.isUTC||!0===t);var u=C.exec(e);return new Date(null!==u?+u[1]:e)}function R(e,t,n){return e=o(e)?new Date:e.length?$(e,t,n):d(e)?new Date(e):V(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function _(e,t){var n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),r=A(O(e),n,"months");return-(n+(t<r?(t-r)/(r-A(O(e),n-1,"months")):(t-r)/(A(O(e),n+1,"months")-r)))||0}function q(e,t){switch(t=y(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function G(e,t){return"ms"===(t=y(t,"ms"))||(q(e,t),A(e,1,t),A(e,-1,"ms")),e}function J(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function K(e,t){var n;return e<0?(n="+",e=Math.abs(e)):n="-",""+n+J(Math.floor(e/60))+(t?"":":")+J(Math.floor(e%60))}function Q(e){return 12<(e=e||24)?e-12:e}function X(e,t,n,r){if(t=R(t),"ms"===(n=y(n,"ms")))switch(r){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var u=+t;switch(r){case"before":return+G(O(e),n)<u;case"after":return+q(O(e),n)>u;default:return+q(O(e),n)<=u&&u<=+G(O(e),n)}}}function ee(e,t,n){return X(e,t,n,"after")}function te(e,t,n){return X(e,t,n,"before")}var ne={add:A,clone:O,dayOfYear:function(e,t){var n=Z(e),r=e.getMonth(),u=0;return g(r,function(e){u+=n[e]}),u+=e.getDate(),j(t)?u:(e.setTime(+e+864e5*(t-u)),e)},daysInMonth:function(e){return Z(e)[e.getMonth()]},diff:function(e,t,n,r){var u,a;switch(t=R(t),n=y(n)){case"Y":u=_(e,t)/12;break;case"M":u=_(e,t);break;case"s":u=(e-t)/1e3;break;case"m":u=(e-t)/6e4;break;case"h":u=(e-t)/36e5;break;case"d":u=(e-t)/864e5;break;default:u=e-t}return r?u:(a=u)<0?Math.ceil(a)||0:Math.floor(a)},endOf:G,format:function(t,e){return e&&"UTC"!==e?e.replace(E,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return J(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return J(t.getDate());case"H":return t.getHours();case"HH":return J(t.getHours());case"h":return Q(t.getHours());case"hh":return J(Q(t.getHours()));case"m":return t.getMinutes();case"mm":return J(t.getMinutes());case"s":return t.getSeconds();case"ss":return J(t.getSeconds());case"SSS":return J(t.getMilliseconds(),3);case"Z":return K(W);case"ZZ":return K(W,!0);default:return e}}):t.toISOString()},get:function(e,t){return t=y(t,"t"),b[t](e)},isAfter:ee,isBefore:te,isBetween:function(e,t,n,r,u){return("("===(u=u||"()").charAt(0)?ee(e,t,r):!te(e,t,r))&&(")"===u.charAt(1)?te(e,n,r):!ee(e,n,r))},isLeapYear:x,isSame:function(e,t,n){return X(e,t,n)},isSameOrAfter:function(e,t,n){return!te(e,t,n)},isSameOrBefore:function(e,t,n){return!ee(e,t,n)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:R,set:function(e,t,n){return(t=y(t))&&b[t](e,n),e},startOf:q,subtract:function(e,t,n){return A(e,-t,n)}};var re={};"Boolean,Number,String,Function,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(e){re["[object "+e+"]"]=e.toLowerCase()});var ue={array:e,camelCase:function(e){return e.replace(n,function(e,t){return t.toUpperCase()})},date:ne,each:v,forEach:a,forIn:function(e,t,n){return e&&h(e,t,n)},forNumber:function(e,t,n){return e&&g(e,t,n)},isArrayLike:f,isAsyncFunction:function(e){return"[object AsyncFunction]"===P(e)},isBoolean:function(e){return"boolean"==typeof e},isDate:V,isFunction:t,isNil:o,isNumber:d,isObject:Y,isPromiseLike:function(e){return!!e&&t(e.then)},isString:l,isUndefined:j,sleep:function(t){return new Promise(function(e){setTimeout(e,t)})},type:function(e){return o(e)?e+"":Y(e)||t(e)?re[P(e)]||"object":typeof e}};module.exports=ue; |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var e,n;e=this,n=function(){"use strict";function c(e,n){return n?e.bind(n):e}function i(e,n,t){for(var r=c(n,t),u=0,a=e.length,i=void 0;!1!==i&&u<a;u++)i=r(e[u],u,e)}function a(e,n,t){return e&&i(e,n,t)}function s(e,n){e[e.length]=n}function r(e,n,t){if(n){if(n.indexOf)return n.indexOf(e,t);for(var r=n.length,u=t?t<0?Math.max(0,r+t):t:0;u<r;u++)if(u in n&&n[u]===e)return u}return-1}function u(n,e){var t=n.length;return a(e,function(e){n[t++]=e}),n.length=t,n}function o(e){return null==e}function n(e){return"function"==typeof e}function d(e){return"number"==typeof e}function f(e){return!o(e)&&d(e.length)&&!n(e)}function l(e){return"string"==typeof e}var m=Array.prototype.push;function h(e,n,t){var r=c(n,t);for(var u in e)if(!1===r(e[u],u,e))break}function g(e,n,t){for(var r=c(n,t),u=0,a=void 0;!1!==a&&u<e;u++)a=r(u,u,u)}function v(e,n,t){e&&(f(e)?i(e,n,t):d(e)?g(e,n,t):h(e,n,t))}function Y(e,n){return e.splice(n,1),n}var e={append:function(e,n){if(e)return e[e.length]=n},forEach:a,grep:function(e,t,r){var u=[];return r=!!r,a(e,function(e,n){!t(e,n)===r&&s(u,e)}),u},inArray:r,includes:function(e,n){return-1!==r(n,e)},join:u,makeArray:function(e,n){var t=n||[];return e&&(f(Object(e))?u(t,l(e)?[e]:e):t.push?t.push(e):m.call(t,e)),t},map:function(e,n,t){var r=[],u=c(n,t);return v(e,function(e){o(e=u(e))||s(r,e)}),r},remove:function(e,n){var t=r(n,e);return 0<=t?(Y(e,t),n):null},removeAt:Y,toArray:function(e){return e&&[].concat(e)}},t=/-([a-z])/g;function p(e){return!o(e)&&"object"==typeof e}function M(e,n){return n?new Date(Date.UTC(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var S={},b=function(e,n){S[e]=S[e.slice(0,-1)]=S[n]=n};function y(e,n){return S[e]||n}b("years","Y"),b("months","M"),b("dates","D"),b("days","d"),b("hours","h"),b("minutes","m"),b("seconds","s"),b("milliseconds","ms");var D={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function H(e){return e=y(e,"ms"),D[e]}function w(e,n,t){var r=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(p(n))h(n,function(e,n){var t=H(n);r[t]+=e});else{var u=H(t);r[u]+=n}return e.setTime(+M(r)),e}function k(e){return new Date(+e)}function x(e){var n=e.getFullYear();return n%4==0&&n%100!=0||n%400==0}var A=[31,28,31,30,31,30,31,31,30,31,30,31],O=[31,29,31,30,31,30,31,31,30,31,30,31];function j(e){return x(e)?O:A}function T(e){return void 0===e}var Z=/^\/?Date\((-?\d+)/i,F=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,C=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],I=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,U=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,B=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],E=/(Z)|[+-](\d\d)(?::?(\d\d))?/,L=(new Date).getTimezoneOffset(),N=Object.prototype.toString;function W(e){return N.call(e)}function z(e){return"[object Date]"===W(e)}function P(e,n,t){if(!l(e))return M(e,!0===n);if(l(n))return M(function(t,r){var e,n=r.length,u=[],a=!1;if(g(n,function(e){var n=t.charAt(e);switch(r.charAt(e)){case"Y":case"y":u[0]=(u[0]||"")+n;break;case"M":u[1]=(u[1]||"")+n;break;case"D":case"d":u[2]=(u[2]||"")+n;break;case"H":case"h":u[3]=(u[3]||"")+n;break;case"m":u[4]=(u[4]||"")+n;break;case"s":u[5]=(u[5]||"")+n;break;case"S":u[6]=(u[6]||"")+n;break;case"Z":a=!0}}),u=u.map(function(e){return parseInt(e,10)}),a)if(e=E.exec(t.slice(-1<r.indexOf("ZZ")?-5:-6))){var i=L;if(!e[1]){var c="+"===e[0].charAt(0)?1:-1;u[3]-=e[2]*c,u[4]-=(e[3]||0)*c}u[4]-=i}else u.isUTC=a&-1<t.indexOf("Z");return o(u[1])||(u[1]-=1),u}(e,n),t);var r=function(e){var t,r,u=[],a=I.exec(e)||F.exec(e);if(a){if(i(C,function(e,n){if(r=e[1].exec(a[1]))return g(3,function(e){u[e]=parseInt(r[e+1]||1,10)}),u[1]-=1,t=!1!==e[2],!1}),e.indexOf(u[0]))return e;if(r=null,a[3]&&i(B,function(e){if(r=e[1].exec(a[3]))return u=u.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!t&&r)return u;if(r=null,a[4]){r=E.exec(a[4]);var n=L;r[1]||(u[3]-=r[2],u[4]-=r[3]||0),u[4]-=n}return u}return 4===e.length&&C[4][1].test(e)?((u=[parseInt(e,10),0,1]).isUTC=!0,u):e}(e);if(r!==e)return M(r,r.isUTC||!0===n);var u=Z.exec(e);return new Date(null!==u?+u[1]:e)}function V(e,n,t){return e=o(e)?new Date:e.length?P(e,n,t):d(e)?new Date(e):z(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function $(e,n){var t=12*(n.getFullYear()-e.getFullYear())+(n.getMonth()-e.getMonth()),r=w(k(e),t,"months");return-(t+(n<r?(n-r)/(r-w(k(e),t-1,"months")):(n-r)/(w(k(e),t+1,"months")-r)))||0}function R(e,n){switch(n=y(n)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function _(e,n){return"ms"===(n=y(n,"ms"))||(R(e,n),w(e,1,n),w(e,-1,"ms")),e}function q(e,n){return void 0===n&&(n=2),("000000"+e).slice(-n)}function G(e,n){var t;return e<0?(t="+",e=Math.abs(e)):t="-",""+t+q(Math.floor(e/60))+(n?"":":")+q(Math.floor(e%60))}function J(e){return 12<(e=e||24)?e-12:e}function K(e,n,t,r){if(n=V(n),"ms"===(t=y(t,"ms")))switch(r){case"before":return+e<+n;case"after":return+n<+e;default:return+e==+n}else{var u=+n;switch(r){case"before":return+_(k(e),t)<u;case"after":return+R(k(e),t)>u;default:return+R(k(e),t)<=u&&u<=+_(k(e),t)}}}function Q(e,n,t){return K(e,n,t,"after")}function X(e,n,t){return K(e,n,t,"before")}var ee={add:w,clone:k,dayOfYear:function(e,n){var t=j(e),r=e.getMonth(),u=0;return g(r,function(e){u+=t[e]}),u+=e.getDate(),T(n)?u:(e.setTime(+e+864e5*(n-u)),e)},daysInMonth:function(e){return j(e)[e.getMonth()]},diff:function(e,n,t,r){var u,a;switch(n=V(n),t=y(t)){case"Y":u=$(e,n)/12;break;case"M":u=$(e,n);break;case"s":u=(e-n)/1e3;break;case"m":u=(e-n)/6e4;break;case"h":u=(e-n)/36e5;break;case"d":u=(e-n)/864e5;break;default:u=e-n}return r?u:(a=u)<0?Math.ceil(a)||0:Math.floor(a)},endOf:_,format:function(n,e){return e&&"UTC"!==e?e.replace(U,function(e){switch(e){case"YY":return String(n.getFullYear()).slice(-2);case"YYYY":case"yyyy":return n.getFullYear();case"M":return n.getMonth()+1;case"MM":return q(n.getMonth()+1);case"D":case"d":return n.getDate();case"DD":case"dd":return q(n.getDate());case"H":return n.getHours();case"HH":return q(n.getHours());case"h":return J(n.getHours());case"hh":return q(J(n.getHours()));case"m":return n.getMinutes();case"mm":return q(n.getMinutes());case"s":return n.getSeconds();case"ss":return q(n.getSeconds());case"SSS":return q(n.getMilliseconds(),3);case"Z":return G(L);case"ZZ":return G(L,!0);default:return e}}):n.toISOString()},isAfter:Q,isBefore:X,isBetween:function(e,n,t,r,u){return("("===(u=u||"()").charAt(0)?Q(e,n,r):!X(e,n,r))&&(")"===u.charAt(1)?X(e,t,r):!Q(e,t,r))},isLeapYear:x,isSame:function(e,n,t){return K(e,n,t)},isSameOrAfter:function(e,n,t){return!X(e,n,t)},isSameOrBefore:function(e,n,t){return!Q(e,n,t)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:V,startOf:R,subtract:function(e,n,t){return w(e,-n,t)}};var ne={};return"Boolean,Number,String,Function,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(e){ne["[object "+e+"]"]=e.toLowerCase()}),{array:e,camelCase:function(e){return e.replace(t,function(e,n){return n.toUpperCase()})},date:ee,each:v,forEach:a,forIn:function(e,n,t){return e&&h(e,n,t)},forNumber:function(e,n,t){return e&&g(e,n,t)},isArrayLike:f,isAsyncFunction:function(e){return"[object AsyncFunction]"===W(e)},isBoolean:function(e){return"boolean"==typeof e},isDate:z,isFunction:n,isNil:o,isNumber:d,isObject:p,isPromiseLike:function(e){return!!e&&n(e.then)},isString:l,isUndefined:T,sleep:function(n){return new Promise(function(e){setTimeout(e,n)})},type:function(e){return o(e)?e+"":p(e)||n(e)?ne[W(e)]||"object":typeof e}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e=e||self).celia=n(); | ||
var e,t;e=this,t=function(){"use strict";function s(e,t){return t?e.bind(t):e}function a(e,t,n){for(var r=s(t,n),u=0,i=e.length,a=void 0;!1!==a&&u<i;u++)a=r(e[u],u,e)}function i(e,t,n){return e&&a(e,t,n)}function c(e,t){e[e.length]=t}function r(e,t,n){if(t){if(t.indexOf)return t.indexOf(e,n);for(var r=t.length,u=n?n<0?Math.max(0,r+n):n:0;u<r;u++)if(u in t&&t[u]===e)return u}return-1}function u(t,e){var n=t.length;return i(e,function(e){t[n++]=e}),t.length=n,t}function o(e){return null==e}function t(e){return"function"==typeof e}function d(e){return"number"==typeof e}function f(e){return!o(e)&&d(e.length)&&!t(e)}function l(e){return"string"==typeof e}var m=Array.prototype.push;function h(e,t,n){var r=s(t,n);for(var u in e)if(!1===r(e[u],u,e))break}function g(e,t,n){for(var r=s(t,n),u=0,i=void 0;!1!==i&&u<e;u++)i=r(u,u,u)}function v(e,t,n){e&&(f(e)?a(e,t,n):d(e)?g(e,t,n):h(e,t,n))}function M(e,t){return e.splice(t,1),t}var e={append:function(e,t){if(e)return e[e.length]=t},forEach:i,grep:function(e,n,r){var u=[];return r=!!r,i(e,function(e,t){!n(e,t)===r&&c(u,e)}),u},inArray:r,includes:function(e,t){return-1!==r(t,e)},join:u,makeArray:function(e,t){var n=t||[];return e&&(f(Object(e))?u(n,l(e)?[e]:e):n.push?n.push(e):m.call(n,e)),n},map:function(e,t,n){var r=[],u=s(t,n);return v(e,function(e){o(e=u(e))||c(r,e)}),r},remove:function(e,t){var n=r(t,e);return 0<=n?(M(e,n),t):null},removeAt:M,toArray:function(e){return e&&[].concat(e)}},n=/-([a-z])/g;function p(e){return!o(e)&&"object"==typeof e}function Y(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,o(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var S=Date.prototype;S.setDay||(S.setDay=function(e){var t=this.getDay();e!==t&&this.setTime(+this+864e5*(e-t))});var D={},y={};function b(e,t){return D[e]||t}function H(e,t,n){var r=e.slice(0,-1);D[t]=D[e]=D[r]=t,y[t]=function(e,t){return o(t)?e["get"+n]():(e["set"+n](t),e)}}H("years","Y","FullYear"),H("months","M","Month"),H("dates","D","Date"),H("days","d","Day"),H("hours","h","Hours"),H("minutes","m","Minutes"),H("seconds","s","Seconds"),H("milliseconds","ms","Milliseconds"),H("times","t","Time");var w={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function k(e){return e=b(e,"ms"),w[e]}function x(e,t,n){var r=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(p(t))h(t,function(e,t){var n=k(t);r[n]+=e});else{var u=k(n);r[u]+=t}return e.setTime(+Y(r)),e}function A(e){return new Date(+e)}function O(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var T=[31,28,31,30,31,30,31,31,30,31,30,31],j=[31,29,31,30,31,30,31,31,30,31,30,31];function F(e){return O(e)?j:T}function Z(e){return void 0===e}var C=/^\/?Date\((-?\d+)/i,I=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,U=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],B=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,E=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,L=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],N=/(Z)|[+-](\d\d)(?::?(\d\d))?/,W=(new Date).getTimezoneOffset(),z=Object.prototype.toString;function P(e){return z.call(e)}function V(e){return"[object Date]"===P(e)}function $(e,t,n){if(!l(e))return Y(e,!0===t);if(l(t))return Y(function(n,r){var e,t=r.length,u=[],i=!1;if(g(t,function(e){var t=n.charAt(e);switch(r.charAt(e)){case"Y":case"y":u[0]=(u[0]||"")+t;break;case"M":u[1]=(u[1]||"")+t;break;case"D":case"d":u[2]=(u[2]||"")+t;break;case"H":case"h":u[3]=(u[3]||"")+t;break;case"m":u[4]=(u[4]||"")+t;break;case"s":u[5]=(u[5]||"")+t;break;case"S":u[6]=(u[6]||"")+t;break;case"Z":i=!0}}),u=u.map(function(e){return parseInt(e,10)}),i)if(e=N.exec(n.slice(-1<r.indexOf("ZZ")?-5:-6))){var a=W;if(!e[1]){var s="+"===e[0].charAt(0)?1:-1;u[3]-=e[2]*s,u[4]-=(e[3]||0)*s}u[4]-=a}else u.isUTC=i&-1<n.indexOf("Z");return o(u[1])||(u[1]-=1),u}(e,t),n);var r=function(e){var n,r,u=[],i=B.exec(e)||I.exec(e);if(i){if(a(U,function(e,t){if(r=e[1].exec(i[1]))return g(3,function(e){u[e]=parseInt(r[e+1]||1,10)}),u[1]-=1,n=!1!==e[2],!1}),e.indexOf(u[0]))return e;if(r=null,i[3]&&a(L,function(e){if(r=e[1].exec(i[3]))return u=u.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!n&&r)return u;if(r=null,i[4]){r=N.exec(i[4]);var t=W;r[1]||(u[3]-=r[2],u[4]-=r[3]||0),u[4]-=t}return u}return 4===e.length&&U[4][1].test(e)?((u=[parseInt(e,10),0,1]).isUTC=!0,u):e}(e);if(r!==e)return Y(r,r.isUTC||!0===t);var u=C.exec(e);return new Date(null!==u?+u[1]:e)}function R(e,t,n){return e=o(e)?new Date:e.length?$(e,t,n):d(e)?new Date(e):V(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function _(e,t){var n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),r=x(A(e),n,"months");return-(n+(t<r?(t-r)/(r-x(A(e),n-1,"months")):(t-r)/(x(A(e),n+1,"months")-r)))||0}function q(e,t){switch(t=b(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function G(e,t){return"ms"===(t=b(t,"ms"))||(q(e,t),x(e,1,t),x(e,-1,"ms")),e}function J(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function K(e,t){var n;return e<0?(n="+",e=Math.abs(e)):n="-",""+n+J(Math.floor(e/60))+(t?"":":")+J(Math.floor(e%60))}function Q(e){return 12<(e=e||24)?e-12:e}function X(e,t,n,r){if(t=R(t),"ms"===(n=b(n,"ms")))switch(r){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var u=+t;switch(r){case"before":return+G(A(e),n)<u;case"after":return+q(A(e),n)>u;default:return+q(A(e),n)<=u&&u<=+G(A(e),n)}}}function ee(e,t,n){return X(e,t,n,"after")}function te(e,t,n){return X(e,t,n,"before")}var ne={add:x,clone:A,dayOfYear:function(e,t){var n=F(e),r=e.getMonth(),u=0;return g(r,function(e){u+=n[e]}),u+=e.getDate(),Z(t)?u:(e.setTime(+e+864e5*(t-u)),e)},daysInMonth:function(e){return F(e)[e.getMonth()]},diff:function(e,t,n,r){var u,i;switch(t=R(t),n=b(n)){case"Y":u=_(e,t)/12;break;case"M":u=_(e,t);break;case"s":u=(e-t)/1e3;break;case"m":u=(e-t)/6e4;break;case"h":u=(e-t)/36e5;break;case"d":u=(e-t)/864e5;break;default:u=e-t}return r?u:(i=u)<0?Math.ceil(i)||0:Math.floor(i)},endOf:G,format:function(t,e){return e&&"UTC"!==e?e.replace(E,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return J(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return J(t.getDate());case"H":return t.getHours();case"HH":return J(t.getHours());case"h":return Q(t.getHours());case"hh":return J(Q(t.getHours()));case"m":return t.getMinutes();case"mm":return J(t.getMinutes());case"s":return t.getSeconds();case"ss":return J(t.getSeconds());case"SSS":return J(t.getMilliseconds(),3);case"Z":return K(W);case"ZZ":return K(W,!0);default:return e}}):t.toISOString()},get:function(e,t){return t=b(t,"t"),y[t](e)},isAfter:ee,isBefore:te,isBetween:function(e,t,n,r,u){return("("===(u=u||"()").charAt(0)?ee(e,t,r):!te(e,t,r))&&(")"===u.charAt(1)?te(e,n,r):!ee(e,n,r))},isLeapYear:O,isSame:function(e,t,n){return X(e,t,n)},isSameOrAfter:function(e,t,n){return!te(e,t,n)},isSameOrBefore:function(e,t,n){return!ee(e,t,n)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:R,set:function(e,t,n){return(t=b(t))&&y[t](e,n),e},startOf:q,subtract:function(e,t,n){return x(e,-t,n)}};var re={};return"Boolean,Number,String,Function,Array,Date,RegExp,Object,Error,Symbol".split(",").forEach(function(e){re["[object "+e+"]"]=e.toLowerCase()}),{array:e,camelCase:function(e){return e.replace(n,function(e,t){return t.toUpperCase()})},date:ne,each:v,forEach:i,forIn:function(e,t,n){return e&&h(e,t,n)},forNumber:function(e,t,n){return e&&g(e,t,n)},isArrayLike:f,isAsyncFunction:function(e){return"[object AsyncFunction]"===P(e)},isBoolean:function(e){return"boolean"==typeof e},isDate:V,isFunction:t,isNil:o,isNumber:d,isObject:p,isPromiseLike:function(e){return!!e&&t(e.then)},isString:l,isUndefined:Z,sleep:function(t){return new Promise(function(e){setTimeout(e,t)})},type:function(e){return o(e)?e+"":p(e)||t(e)?re[P(e)]||"object":typeof e}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).celia=t(); |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -56,19 +56,41 @@ * Released under the MIT License. | ||
var dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
var day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
var UNITS = {}; | ||
var setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
var fns = {}; | ||
function normalizeUnit (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
var longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[("get" + method)](); | ||
} else { | ||
date[("set" + method)](val); | ||
return date; | ||
} | ||
}; | ||
}setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
var indexOfUnits = { | ||
@@ -85,3 +107,3 @@ Y: 0, | ||
function getIndex(units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
return indexOfUnits[units]; | ||
@@ -421,3 +443,3 @@ } | ||
var output; | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
@@ -452,3 +474,3 @@ switch (units) { | ||
function startOf (date, units) { | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
switch (units) { | ||
@@ -479,3 +501,3 @@ case 'Y': | ||
function endOf (date, units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -563,5 +585,10 @@ return date; | ||
function get (date, unit) { | ||
unit = normalize(unit, 't'); | ||
return fns[unit](date); | ||
} | ||
function compare (date, input, units, type) { | ||
input = parse(input); | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -619,2 +646,8 @@ switch (type) { | ||
function set (date, unit, val) { | ||
unit = normalize(unit); | ||
unit && fns[unit](date, val); | ||
return date; | ||
} | ||
function subtract (date, num, unit) { | ||
@@ -632,2 +665,3 @@ return add(date, -num, unit); | ||
format: format, | ||
get: get, | ||
isAfter: isAfter, | ||
@@ -642,2 +676,3 @@ isBefore: isBefore, | ||
parse: parse, | ||
set: set, | ||
startOf: startOf, | ||
@@ -644,0 +679,0 @@ subtract: subtract |
71
date.js
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -60,19 +60,41 @@ * Released under the MIT License. | ||
var dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
var day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
var UNITS = {}; | ||
var setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
var fns = {}; | ||
function normalizeUnit (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
var longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[("get" + method)](); | ||
} else { | ||
date[("set" + method)](val); | ||
return date; | ||
} | ||
}; | ||
}setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
var indexOfUnits = { | ||
@@ -89,3 +111,3 @@ Y: 0, | ||
function getIndex(units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
return indexOfUnits[units]; | ||
@@ -425,3 +447,3 @@ } | ||
var output; | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
@@ -456,3 +478,3 @@ switch (units) { | ||
function startOf (date, units) { | ||
units = normalizeUnit(units); | ||
units = normalize(units); | ||
switch (units) { | ||
@@ -483,3 +505,3 @@ case 'Y': | ||
function endOf (date, units) { | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -567,5 +589,10 @@ return date; | ||
function get (date, unit) { | ||
unit = normalize(unit, 't'); | ||
return fns[unit](date); | ||
} | ||
function compare (date, input, units, type) { | ||
input = parse(input); | ||
units = normalizeUnit(units, 'ms'); | ||
units = normalize(units, 'ms'); | ||
if (units === 'ms') { | ||
@@ -623,2 +650,8 @@ switch (type) { | ||
function set (date, unit, val) { | ||
unit = normalize(unit); | ||
unit && fns[unit](date, val); | ||
return date; | ||
} | ||
function subtract (date, num, unit) { | ||
@@ -636,2 +669,3 @@ return add(date, -num, unit); | ||
format: format, | ||
get: get, | ||
isAfter: isAfter, | ||
@@ -646,2 +680,3 @@ isBefore: isBefore, | ||
parse: parse, | ||
set: set, | ||
startOf: startOf, | ||
@@ -648,0 +683,0 @@ subtract: subtract |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
"use strict";function c(e){return null==e}function u(e,t){return t?e.bind(t):e}function a(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var r={},e=function(e,t){r[e]=r[e.slice(0,-1)]=r[t]=t};function i(e,t){return r[e]||t}e("years","Y"),e("months","M"),e("dates","D"),e("days","d"),e("hours","h"),e("minutes","m"),e("seconds","s"),e("milliseconds","ms");var t={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function o(e){return e=i(e,"ms"),t[e]}function d(e,t,r){var n,d=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(c(n=t)||"object"!=typeof n){var s=o(r);d[s]+=t}else!function(e,t,r){var n=u(t,r);for(var d in e)if(!1===n(e[d],d,e))break}(t,function(e,t){var r=o(t);d[r]+=e});return e.setTime(+a(d)),e}function s(e){return new Date(+e)}function n(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var f=[31,28,31,30,31,30,31,31,30,31,30,31],l=[31,29,31,30,31,30,31,31,30,31,30,31];function m(e){return n(e)?l:f}function h(e,t,r){for(var n=u(t,r),d=0,s=void 0;!1!==s&&d<e;d++)s=n(d,d,d)}var g=/^\/?Date\((-?\d+)/i,Y=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,M=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],S=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,v=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,D=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],H=/(Z)|[+-](\d\d)(?::?(\d\d))?/,b=(new Date).getTimezoneOffset();function w(e){return"string"==typeof e}function p(e,t,r){for(var n=u(t,r),d=0,s=e.length,a=void 0;!1!==a&&d<s;d++)a=n(e[d],d,e)}var k=Object.prototype.toString;function y(e){return"[object Date]"===(t=e,k.call(t));var t}function x(e,t,r){if(!w(e))return a(e,!0===t);if(w(t))return a(function(r,n){var e,t=n.length,d=[],s=!1;if(h(t,function(e){var t=r.charAt(e);switch(n.charAt(e)){case"Y":case"y":d[0]=(d[0]||"")+t;break;case"M":d[1]=(d[1]||"")+t;break;case"D":case"d":d[2]=(d[2]||"")+t;break;case"H":case"h":d[3]=(d[3]||"")+t;break;case"m":d[4]=(d[4]||"")+t;break;case"s":d[5]=(d[5]||"")+t;break;case"S":d[6]=(d[6]||"")+t;break;case"Z":s=!0}}),d=d.map(function(e){return parseInt(e,10)}),s)if(e=H.exec(r.slice(-1<n.indexOf("ZZ")?-5:-6))){var a=b;if(!e[1]){var u="+"===e[0].charAt(0)?1:-1;d[3]-=e[2]*u,d[4]-=(e[3]||0)*u}d[4]-=a}else d.isUTC=s&-1<r.indexOf("Z");return c(d[1])||(d[1]-=1),d}(e,t),r);var n=function(e){var r,n,d=[],s=S.exec(e)||Y.exec(e);if(s){if(p(M,function(e,t){if(n=e[1].exec(s[1]))return h(3,function(e){d[e]=parseInt(n[e+1]||1,10)}),d[1]-=1,r=!1!==e[2],!1}),e.indexOf(d[0]))return e;if(n=null,s[3]&&p(D,function(e){if(n=e[1].exec(s[3]))return d=d.concat(n.slice(1).map(function(e){return parseInt(e,10)})),!1}),!r&&n)return d;if(n=null,s[4]){n=H.exec(s[4]);var t=b;n[1]||(d[3]-=n[2],d[4]-=n[3]||0),d[4]-=t}return d}return 4===e.length&&M[4][1].test(e)?((d=[parseInt(e,10),0,1]).isUTC=!0,d):e}(e);if(n!==e)return a(n,n.isUTC||!0===t);var d=g.exec(e);return new Date(null!==d?+d[1]:e)}function O(e,t,r){return e=c(e)?new Date:e.length?x(e,t,r):"number"==typeof e?new Date(e):y(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function Z(e,t){var r=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),n=d(s(e),r,"months");return-(r+(t<n?(t-n)/(n-d(s(e),r-1,"months")):(t-n)/(d(s(e),r+1,"months")-n)))||0}function T(e,t){switch(t=i(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function A(e,t){return"ms"===(t=i(t,"ms"))||(T(e,t),d(e,1,t),d(e,-1,"ms")),e}function I(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function F(e,t){var r;return e<0?(r="+",e=Math.abs(e)):r="-",""+r+I(Math.floor(e/60))+(t?"":":")+I(Math.floor(e%60))}function C(e){return 12<(e=e||24)?e-12:e}function U(e,t,r,n){if(t=O(t),"ms"===(r=i(r,"ms")))switch(n){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var d=+t;switch(n){case"before":return+A(s(e),r)<d;case"after":return+T(s(e),r)>d;default:return+T(s(e),r)<=d&&d<=+A(s(e),r)}}}function W(e,t,r){return U(e,t,r,"after")}function j(e,t,r){return U(e,t,r,"before")}var B={add:d,clone:s,dayOfYear:function(e,t){var r=m(e),n=e.getMonth(),d=0;return h(n,function(e){d+=r[e]}),d+=e.getDate(),void 0===t?d:(e.setTime(+e+864e5*(t-d)),e)},daysInMonth:function(e){return m(e)[e.getMonth()]},diff:function(e,t,r,n){var d,s;switch(t=O(t),r=i(r)){case"Y":d=Z(e,t)/12;break;case"M":d=Z(e,t);break;case"s":d=(e-t)/1e3;break;case"m":d=(e-t)/6e4;break;case"h":d=(e-t)/36e5;break;case"d":d=(e-t)/864e5;break;default:d=e-t}return n?d:(s=d)<0?Math.ceil(s)||0:Math.floor(s)},endOf:A,format:function(t,e){return e&&"UTC"!==e?e.replace(v,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return I(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return I(t.getDate());case"H":return t.getHours();case"HH":return I(t.getHours());case"h":return C(t.getHours());case"hh":return I(C(t.getHours()));case"m":return t.getMinutes();case"mm":return I(t.getMinutes());case"s":return t.getSeconds();case"ss":return I(t.getSeconds());case"SSS":return I(t.getMilliseconds(),3);case"Z":return F(b);case"ZZ":return F(b,!0);default:return e}}):t.toISOString()},isAfter:W,isBefore:j,isBetween:function(e,t,r,n,d){return("("===(d=d||"()").charAt(0)?W(e,t,n):!j(e,t,n))&&(")"===d.charAt(1)?j(e,r,n):!W(e,r,n))},isLeapYear:n,isSame:function(e,t,r){return U(e,t,r)},isSameOrAfter:function(e,t,r){return!j(e,t,r)},isSameOrBefore:function(e,t,r){return!W(e,t,r)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:O,startOf:T,subtract:function(e,t,r){return d(e,-t,r)}};module.exports=B; | ||
"use strict";function c(e){return null==e}function u(e,t){return t?e.bind(t):e}function d(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var e=Date.prototype;e.setDay||(e.setDay=function(e){var t=this.getDay();e!==t&&this.setTime(+this+864e5*(e-t))});var s={},a={};function i(e,t){return s[e]||t}function t(e,t,r){var n=e.slice(0,-1);s[t]=s[e]=s[n]=t,a[t]=function(e,t){return c(t)?e["get"+r]():(e["set"+r](t),e)}}t("years","Y","FullYear"),t("months","M","Month"),t("dates","D","Date"),t("days","d","Day"),t("hours","h","Hours"),t("minutes","m","Minutes"),t("seconds","s","Seconds"),t("milliseconds","ms","Milliseconds"),t("times","t","Time");var r={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function o(e){return e=i(e,"ms"),r[e]}function f(e,t,r){var n,s=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(c(n=t)||"object"!=typeof n){var a=o(r);s[a]+=t}else!function(e,t,r){var n=u(t,r);for(var s in e)if(!1===n(e[s],s,e))break}(t,function(e,t){var r=o(t);s[r]+=e});return e.setTime(+d(s)),e}function l(e){return new Date(+e)}function n(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var m=[31,28,31,30,31,30,31,31,30,31,30,31],h=[31,29,31,30,31,30,31,31,30,31,30,31];function g(e){return n(e)?h:m}function M(e,t,r){for(var n=u(t,r),s=0,a=void 0;!1!==a&&s<e;s++)a=n(s,s,s)}var Y=/^\/?Date\((-?\d+)/i,v=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,D=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],S=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,H=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,b=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],y=/(Z)|[+-](\d\d)(?::?(\d\d))?/,p=(new Date).getTimezoneOffset();function w(e){return"string"==typeof e}function k(e,t,r){for(var n=u(t,r),s=0,a=e.length,d=void 0;!1!==d&&s<a;s++)d=n(e[s],s,e)}var T=Object.prototype.toString;function x(e){return"[object Date]"===(t=e,T.call(t));var t}function O(e,t,r){if(!w(e))return d(e,!0===t);if(w(t))return d(function(r,n){var e,t=n.length,s=[],a=!1;if(M(t,function(e){var t=r.charAt(e);switch(n.charAt(e)){case"Y":case"y":s[0]=(s[0]||"")+t;break;case"M":s[1]=(s[1]||"")+t;break;case"D":case"d":s[2]=(s[2]||"")+t;break;case"H":case"h":s[3]=(s[3]||"")+t;break;case"m":s[4]=(s[4]||"")+t;break;case"s":s[5]=(s[5]||"")+t;break;case"S":s[6]=(s[6]||"")+t;break;case"Z":a=!0}}),s=s.map(function(e){return parseInt(e,10)}),a)if(e=y.exec(r.slice(-1<n.indexOf("ZZ")?-5:-6))){var d=p;if(!e[1]){var u="+"===e[0].charAt(0)?1:-1;s[3]-=e[2]*u,s[4]-=(e[3]||0)*u}s[4]-=d}else s.isUTC=a&-1<r.indexOf("Z");return c(s[1])||(s[1]-=1),s}(e,t),r);var n=function(e){var r,n,s=[],a=S.exec(e)||v.exec(e);if(a){if(k(D,function(e,t){if(n=e[1].exec(a[1]))return M(3,function(e){s[e]=parseInt(n[e+1]||1,10)}),s[1]-=1,r=!1!==e[2],!1}),e.indexOf(s[0]))return e;if(n=null,a[3]&&k(b,function(e){if(n=e[1].exec(a[3]))return s=s.concat(n.slice(1).map(function(e){return parseInt(e,10)})),!1}),!r&&n)return s;if(n=null,a[4]){n=y.exec(a[4]);var t=p;n[1]||(s[3]-=n[2],s[4]-=n[3]||0),s[4]-=t}return s}return 4===e.length&&D[4][1].test(e)?((s=[parseInt(e,10),0,1]).isUTC=!0,s):e}(e);if(n!==e)return d(n,n.isUTC||!0===t);var s=Y.exec(e);return new Date(null!==s?+s[1]:e)}function Z(e,t,r){return e=c(e)?new Date:e.length?O(e,t,r):"number"==typeof e?new Date(e):x(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function A(e,t){var r=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),n=f(l(e),r,"months");return-(r+(t<n?(t-n)/(n-f(l(e),r-1,"months")):(t-n)/(f(l(e),r+1,"months")-n)))||0}function F(e,t){switch(t=i(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function I(e,t){return"ms"===(t=i(t,"ms"))||(F(e,t),f(e,1,t),f(e,-1,"ms")),e}function C(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function U(e,t){var r;return e<0?(r="+",e=Math.abs(e)):r="-",""+r+C(Math.floor(e/60))+(t?"":":")+C(Math.floor(e%60))}function W(e){return 12<(e=e||24)?e-12:e}function j(e,t,r,n){if(t=Z(t),"ms"===(r=i(r,"ms")))switch(n){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var s=+t;switch(n){case"before":return+I(l(e),r)<s;case"after":return+F(l(e),r)>s;default:return+F(l(e),r)<=s&&s<=+I(l(e),r)}}}function B(e,t,r){return j(e,t,r,"after")}function V(e,t,r){return j(e,t,r,"before")}var $={add:f,clone:l,dayOfYear:function(e,t){var r=g(e),n=e.getMonth(),s=0;return M(n,function(e){s+=r[e]}),s+=e.getDate(),void 0===t?s:(e.setTime(+e+864e5*(t-s)),e)},daysInMonth:function(e){return g(e)[e.getMonth()]},diff:function(e,t,r,n){var s,a;switch(t=Z(t),r=i(r)){case"Y":s=A(e,t)/12;break;case"M":s=A(e,t);break;case"s":s=(e-t)/1e3;break;case"m":s=(e-t)/6e4;break;case"h":s=(e-t)/36e5;break;case"d":s=(e-t)/864e5;break;default:s=e-t}return n?s:(a=s)<0?Math.ceil(a)||0:Math.floor(a)},endOf:I,format:function(t,e){return e&&"UTC"!==e?e.replace(H,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return C(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return C(t.getDate());case"H":return t.getHours();case"HH":return C(t.getHours());case"h":return W(t.getHours());case"hh":return C(W(t.getHours()));case"m":return t.getMinutes();case"mm":return C(t.getMinutes());case"s":return t.getSeconds();case"ss":return C(t.getSeconds());case"SSS":return C(t.getMilliseconds(),3);case"Z":return U(p);case"ZZ":return U(p,!0);default:return e}}):t.toISOString()},get:function(e,t){return t=i(t,"t"),a[t](e)},isAfter:B,isBefore:V,isBetween:function(e,t,r,n,s){return("("===(s=s||"()").charAt(0)?B(e,t,n):!V(e,t,n))&&(")"===s.charAt(1)?V(e,r,n):!B(e,r,n))},isLeapYear:n,isSame:function(e,t,r){return j(e,t,r)},isSameOrAfter:function(e,t,r){return!V(e,t,r)},isSameOrBefore:function(e,t,r){return!B(e,t,r)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:Z,set:function(e,t,r){return(t=i(t))&&a[t](e,r),e},startOf:F,subtract:function(e,t,r){return f(e,-t,r)}};module.exports=$; |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
* Released under the MIT License. | ||
*/ | ||
var e,t;e=this,t=function(){"use strict";function c(e){return null==e}function u(e,t){return t?e.bind(t):e}function a(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var n={},e=function(e,t){n[e]=n[e.slice(0,-1)]=n[t]=t};function i(e,t){return n[e]||t}e("years","Y"),e("months","M"),e("dates","D"),e("days","d"),e("hours","h"),e("minutes","m"),e("seconds","s"),e("milliseconds","ms");var t={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function o(e){return e=i(e,"ms"),t[e]}function d(e,t,n){var r,d=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(c(r=t)||"object"!=typeof r){var s=o(n);d[s]+=t}else!function(e,t,n){var r=u(t,n);for(var d in e)if(!1===r(e[d],d,e))break}(t,function(e,t){var n=o(t);d[n]+=e});return e.setTime(+a(d)),e}function s(e){return new Date(+e)}function r(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var f=[31,28,31,30,31,30,31,31,30,31,30,31],l=[31,29,31,30,31,30,31,31,30,31,30,31];function m(e){return r(e)?l:f}function h(e,t,n){for(var r=u(t,n),d=0,s=void 0;!1!==s&&d<e;d++)s=r(d,d,d)}var g=/^\/?Date\((-?\d+)/i,Y=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,M=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],S=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,v=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,D=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],H=/(Z)|[+-](\d\d)(?::?(\d\d))?/,b=(new Date).getTimezoneOffset();function p(e){return"string"==typeof e}function w(e,t,n){for(var r=u(t,n),d=0,s=e.length,a=void 0;!1!==a&&d<s;d++)a=r(e[d],d,e)}var y=Object.prototype.toString;function k(e){return"[object Date]"===(t=e,y.call(t));var t}function x(e,t,n){if(!p(e))return a(e,!0===t);if(p(t))return a(function(n,r){var e,t=r.length,d=[],s=!1;if(h(t,function(e){var t=n.charAt(e);switch(r.charAt(e)){case"Y":case"y":d[0]=(d[0]||"")+t;break;case"M":d[1]=(d[1]||"")+t;break;case"D":case"d":d[2]=(d[2]||"")+t;break;case"H":case"h":d[3]=(d[3]||"")+t;break;case"m":d[4]=(d[4]||"")+t;break;case"s":d[5]=(d[5]||"")+t;break;case"S":d[6]=(d[6]||"")+t;break;case"Z":s=!0}}),d=d.map(function(e){return parseInt(e,10)}),s)if(e=H.exec(n.slice(-1<r.indexOf("ZZ")?-5:-6))){var a=b;if(!e[1]){var u="+"===e[0].charAt(0)?1:-1;d[3]-=e[2]*u,d[4]-=(e[3]||0)*u}d[4]-=a}else d.isUTC=s&-1<n.indexOf("Z");return c(d[1])||(d[1]-=1),d}(e,t),n);var r=function(e){var n,r,d=[],s=S.exec(e)||Y.exec(e);if(s){if(w(M,function(e,t){if(r=e[1].exec(s[1]))return h(3,function(e){d[e]=parseInt(r[e+1]||1,10)}),d[1]-=1,n=!1!==e[2],!1}),e.indexOf(d[0]))return e;if(r=null,s[3]&&w(D,function(e){if(r=e[1].exec(s[3]))return d=d.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!n&&r)return d;if(r=null,s[4]){r=H.exec(s[4]);var t=b;r[1]||(d[3]-=r[2],d[4]-=r[3]||0),d[4]-=t}return d}return 4===e.length&&M[4][1].test(e)?((d=[parseInt(e,10),0,1]).isUTC=!0,d):e}(e);if(r!==e)return a(r,r.isUTC||!0===t);var d=g.exec(e);return new Date(null!==d?+d[1]:e)}function O(e,t,n){return e=c(e)?new Date:e.length?x(e,t,n):"number"==typeof e?new Date(e):k(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function Z(e,t){var n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),r=d(s(e),n,"months");return-(n+(t<r?(t-r)/(r-d(s(e),n-1,"months")):(t-r)/(d(s(e),n+1,"months")-r)))||0}function T(e,t){switch(t=i(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function A(e,t){return"ms"===(t=i(t,"ms"))||(T(e,t),d(e,1,t),d(e,-1,"ms")),e}function I(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function F(e,t){var n;return e<0?(n="+",e=Math.abs(e)):n="-",""+n+I(Math.floor(e/60))+(t?"":":")+I(Math.floor(e%60))}function C(e){return 12<(e=e||24)?e-12:e}function U(e,t,n,r){if(t=O(t),"ms"===(n=i(n,"ms")))switch(r){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var d=+t;switch(r){case"before":return+A(s(e),n)<d;case"after":return+T(s(e),n)>d;default:return+T(s(e),n)<=d&&d<=+A(s(e),n)}}}function j(e,t,n){return U(e,t,n,"after")}function W(e,t,n){return U(e,t,n,"before")}return{add:d,clone:s,dayOfYear:function(e,t){var n=m(e),r=e.getMonth(),d=0;return h(r,function(e){d+=n[e]}),d+=e.getDate(),void 0===t?d:(e.setTime(+e+864e5*(t-d)),e)},daysInMonth:function(e){return m(e)[e.getMonth()]},diff:function(e,t,n,r){var d,s;switch(t=O(t),n=i(n)){case"Y":d=Z(e,t)/12;break;case"M":d=Z(e,t);break;case"s":d=(e-t)/1e3;break;case"m":d=(e-t)/6e4;break;case"h":d=(e-t)/36e5;break;case"d":d=(e-t)/864e5;break;default:d=e-t}return r?d:(s=d)<0?Math.ceil(s)||0:Math.floor(s)},endOf:A,format:function(t,e){return e&&"UTC"!==e?e.replace(v,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return I(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return I(t.getDate());case"H":return t.getHours();case"HH":return I(t.getHours());case"h":return C(t.getHours());case"hh":return I(C(t.getHours()));case"m":return t.getMinutes();case"mm":return I(t.getMinutes());case"s":return t.getSeconds();case"ss":return I(t.getSeconds());case"SSS":return I(t.getMilliseconds(),3);case"Z":return F(b);case"ZZ":return F(b,!0);default:return e}}):t.toISOString()},isAfter:j,isBefore:W,isBetween:function(e,t,n,r,d){return("("===(d=d||"()").charAt(0)?j(e,t,r):!W(e,t,r))&&(")"===d.charAt(1)?W(e,n,r):!j(e,n,r))},isLeapYear:r,isSame:function(e,t,n){return U(e,t,n)},isSameOrAfter:function(e,t,n){return!W(e,t,n)},isSameOrBefore:function(e,t,n){return!j(e,t,n)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:O,startOf:T,subtract:function(e,t,n){return d(e,-t,n)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).celia=t(); | ||
var e,t;e=this,t=function(){"use strict";function c(e){return null==e}function u(e,t){return t?e.bind(t):e}function a(e,t){return t?new Date(Date.UTC(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)):new Date(e[0],e[1]||0,c(e[2])?1:e[2],e[3]||0,e[4]||0,e[5]||0,e[6]||0)}var e=Date.prototype;e.setDay||(e.setDay=function(e){var t=this.getDay();e!==t&&this.setTime(+this+864e5*(e-t))});var s={},d={};function i(e,t){return s[e]||t}function t(e,t,n){var r=e.slice(0,-1);s[t]=s[e]=s[r]=t,d[t]=function(e,t){return c(t)?e["get"+n]():(e["set"+n](t),e)}}t("years","Y","FullYear"),t("months","M","Month"),t("dates","D","Date"),t("days","d","Day"),t("hours","h","Hours"),t("minutes","m","Minutes"),t("seconds","s","Seconds"),t("milliseconds","ms","Milliseconds"),t("times","t","Time");var n={Y:0,M:1,d:2,h:3,m:4,s:5,ms:6};function o(e){return e=i(e,"ms"),n[e]}function f(e,t,n){var r,s=[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];if(c(r=t)||"object"!=typeof r){var d=o(n);s[d]+=t}else!function(e,t,n){var r=u(t,n);for(var s in e)if(!1===r(e[s],s,e))break}(t,function(e,t){var n=o(t);s[n]+=e});return e.setTime(+a(s)),e}function l(e){return new Date(+e)}function r(e){var t=e.getFullYear();return t%4==0&&t%100!=0||t%400==0}var m=[31,28,31,30,31,30,31,31,30,31,30,31],h=[31,29,31,30,31,30,31,31,30,31,30,31];function g(e){return r(e)?h:m}function M(e,t,n){for(var r=u(t,n),s=0,d=void 0;!1!==d&&s<e;s++)d=r(s,s,s)}var Y=/^\/?Date\((-?\d+)/i,v=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,D=[["YYYY-MM-DD",/(\d{4})-(\d\d)-(\d\d)/],["YYYY-MM",/(\d{4})-(\d\d)/,!1],["YYYYMMDD",/(\d{4})(\d\d)(\d\d)/],["YYYYMM",/(\d{4})(\d\d)/,!1],["YYYY",/\d{4}/,!1]],S=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)\s*([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/,H=/\[.*?\]|Y{2,4}|y{2,4}|M{1,2}|D{1,2}|d{1,2}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|SSS|Z{1,2}/g,b=[["HH:mm:ss.SSSS",/(\d\d):(\d\d):(\d\d)\.(\d+)/],["HH:mm:ss,SSSS",/(\d\d):(\d\d):(\d\d),(\d+)/],["HH:mm:ss",/(\d\d):(\d\d):(\d\d)/],["HH:mm",/(\d\d):(\d\d)/],["HHmmss.SSSS",/(\d\d)(\d\d)(\d\d)\.(\d+)/],["HHmmss,SSSS",/(\d\d)(\d\d)(\d\d),(\d+)/],["HHmmss",/(\d\d)(\d\d)(\d\d)/],["HHmm",/(\d\d)(\d\d)/],["HH",/\d\d/]],y=/(Z)|[+-](\d\d)(?::?(\d\d))?/,p=(new Date).getTimezoneOffset();function w(e){return"string"==typeof e}function k(e,t,n){for(var r=u(t,n),s=0,d=e.length,a=void 0;!1!==a&&s<d;s++)a=r(e[s],s,e)}var x=Object.prototype.toString;function T(e){return"[object Date]"===(t=e,x.call(t));var t}function O(e,t,n){if(!w(e))return a(e,!0===t);if(w(t))return a(function(n,r){var e,t=r.length,s=[],d=!1;if(M(t,function(e){var t=n.charAt(e);switch(r.charAt(e)){case"Y":case"y":s[0]=(s[0]||"")+t;break;case"M":s[1]=(s[1]||"")+t;break;case"D":case"d":s[2]=(s[2]||"")+t;break;case"H":case"h":s[3]=(s[3]||"")+t;break;case"m":s[4]=(s[4]||"")+t;break;case"s":s[5]=(s[5]||"")+t;break;case"S":s[6]=(s[6]||"")+t;break;case"Z":d=!0}}),s=s.map(function(e){return parseInt(e,10)}),d)if(e=y.exec(n.slice(-1<r.indexOf("ZZ")?-5:-6))){var a=p;if(!e[1]){var u="+"===e[0].charAt(0)?1:-1;s[3]-=e[2]*u,s[4]-=(e[3]||0)*u}s[4]-=a}else s.isUTC=d&-1<n.indexOf("Z");return c(s[1])||(s[1]-=1),s}(e,t),n);var r=function(e){var n,r,s=[],d=S.exec(e)||v.exec(e);if(d){if(k(D,function(e,t){if(r=e[1].exec(d[1]))return M(3,function(e){s[e]=parseInt(r[e+1]||1,10)}),s[1]-=1,n=!1!==e[2],!1}),e.indexOf(s[0]))return e;if(r=null,d[3]&&k(b,function(e){if(r=e[1].exec(d[3]))return s=s.concat(r.slice(1).map(function(e){return parseInt(e,10)})),!1}),!n&&r)return s;if(r=null,d[4]){r=y.exec(d[4]);var t=p;r[1]||(s[3]-=r[2],s[4]-=r[3]||0),s[4]-=t}return s}return 4===e.length&&D[4][1].test(e)?((s=[parseInt(e,10),0,1]).isUTC=!0,s):e}(e);if(r!==e)return a(r,r.isUTC||!0===t);var s=Y.exec(e);return new Date(null!==s?+s[1]:e)}function Z(e,t,n){return e=c(e)?new Date:e.length?O(e,t,n):"number"==typeof e?new Date(e):T(e)?new Date(+e):e._i&&e.isValid()?new Date(+e):new Date}function A(e,t){var n=12*(t.getFullYear()-e.getFullYear())+(t.getMonth()-e.getMonth()),r=f(l(e),n,"months");return-(n+(t<r?(t-r)/(r-f(l(e),n-1,"months")):(t-r)/(f(l(e),n+1,"months")-r)))||0}function F(e,t){switch(t=i(t)){case"Y":e.setMonth(0);case"M":e.setDate(1);case"D":case"d":e.setHours(0);case"h":e.setMinutes(0);case"m":e.setSeconds(0);case"s":e.setMilliseconds(0)}return e}function I(e,t){return"ms"===(t=i(t,"ms"))||(F(e,t),f(e,1,t),f(e,-1,"ms")),e}function C(e,t){return void 0===t&&(t=2),("000000"+e).slice(-t)}function U(e,t){var n;return e<0?(n="+",e=Math.abs(e)):n="-",""+n+C(Math.floor(e/60))+(t?"":":")+C(Math.floor(e%60))}function j(e){return 12<(e=e||24)?e-12:e}function W(e,t,n,r){if(t=Z(t),"ms"===(n=i(n,"ms")))switch(r){case"before":return+e<+t;case"after":return+t<+e;default:return+e==+t}else{var s=+t;switch(r){case"before":return+I(l(e),n)<s;case"after":return+F(l(e),n)>s;default:return+F(l(e),n)<=s&&s<=+I(l(e),n)}}}function B(e,t,n){return W(e,t,n,"after")}function V(e,t,n){return W(e,t,n,"before")}return{add:f,clone:l,dayOfYear:function(e,t){var n=g(e),r=e.getMonth(),s=0;return M(r,function(e){s+=n[e]}),s+=e.getDate(),void 0===t?s:(e.setTime(+e+864e5*(t-s)),e)},daysInMonth:function(e){return g(e)[e.getMonth()]},diff:function(e,t,n,r){var s,d;switch(t=Z(t),n=i(n)){case"Y":s=A(e,t)/12;break;case"M":s=A(e,t);break;case"s":s=(e-t)/1e3;break;case"m":s=(e-t)/6e4;break;case"h":s=(e-t)/36e5;break;case"d":s=(e-t)/864e5;break;default:s=e-t}return r?s:(d=s)<0?Math.ceil(d)||0:Math.floor(d)},endOf:I,format:function(t,e){return e&&"UTC"!==e?e.replace(H,function(e){switch(e){case"YY":return String(t.getFullYear()).slice(-2);case"YYYY":case"yyyy":return t.getFullYear();case"M":return t.getMonth()+1;case"MM":return C(t.getMonth()+1);case"D":case"d":return t.getDate();case"DD":case"dd":return C(t.getDate());case"H":return t.getHours();case"HH":return C(t.getHours());case"h":return j(t.getHours());case"hh":return C(j(t.getHours()));case"m":return t.getMinutes();case"mm":return C(t.getMinutes());case"s":return t.getSeconds();case"ss":return C(t.getSeconds());case"SSS":return C(t.getMilliseconds(),3);case"Z":return U(p);case"ZZ":return U(p,!0);default:return e}}):t.toISOString()},get:function(e,t){return t=i(t,"t"),d[t](e)},isAfter:B,isBefore:V,isBetween:function(e,t,n,r,s){return("("===(s=s||"()").charAt(0)?B(e,t,r):!V(e,t,r))&&(")"===s.charAt(1)?V(e,n,r):!B(e,n,r))},isLeapYear:r,isSame:function(e,t,n){return W(e,t,n)},isSameOrAfter:function(e,t,n){return!V(e,t,n)},isSameOrBefore:function(e,t,n){return!B(e,t,n)},isValid:function(e){return"Invalid Date"!==e.toString()},parse:Z,set:function(e,t,n){return(t=i(t))&&d[t](e,n),e},startOf:F,subtract:function(e,t,n){return f(e,-t,n)}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).celia=t(); |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
/*! | ||
* celia.js v3.0.1 | ||
* celia.js v3.0.5 | ||
* (c) 2018-2019 Jesse Feng | ||
@@ -4,0 +4,0 @@ * Released under the MIT License. |
@@ -0,16 +1,43 @@ | ||
import isNil from '../../isNil'; | ||
const dateProto = Date.prototype; | ||
/* eslint no-extend-native: 0 */ | ||
if (!dateProto.setDay) { | ||
dateProto.setDay = function (val) { | ||
const day = this.getDay(); | ||
if (val !== day) { | ||
this.setTime(+this + ((val - day) * 86400000)); | ||
} | ||
}; | ||
} | ||
const UNITS = {}; | ||
const setter = function (val, key) { | ||
UNITS[val] = UNITS[val.slice(0, -1)] = UNITS[key] = key; | ||
}; | ||
setter('years', 'Y'); | ||
setter('months', 'M'); | ||
setter('dates', 'D'); | ||
setter('days', 'd'); | ||
setter('hours', 'h'); | ||
setter('minutes', 'm'); | ||
setter('seconds', 's'); | ||
setter('milliseconds', 'ms'); | ||
export const fns = {}; | ||
export default function (u, defaultValue) { | ||
function normalize(u, defaultValue) { | ||
return UNITS[u] || defaultValue; | ||
} | ||
function setter(longer, shorter, method) { | ||
const longerish = longer.slice(0, -1); | ||
UNITS[shorter] = UNITS[longer] = UNITS[longerish] = shorter; | ||
fns[shorter] = function (date, val) { | ||
if (isNil(val)) { | ||
return date[`get${method}`](); | ||
} else { | ||
date[`set${method}`](val); | ||
return date; | ||
} | ||
}; | ||
}; | ||
setter('years', 'Y', 'FullYear'); | ||
setter('months', 'M', 'Month'); | ||
setter('dates', 'D', 'Date'); | ||
setter('days', 'd', 'Day'); | ||
setter('hours', 'h', 'Hours'); | ||
setter('minutes', 'm', 'Minutes'); | ||
setter('seconds', 's', 'Seconds'); | ||
setter('milliseconds', 'ms', 'Milliseconds'); | ||
setter('times', 't', 'Time'); | ||
export default normalize; |
@@ -8,2 +8,3 @@ import add from './date/add.js'; | ||
import format from './date/format.js'; | ||
import get from './date/get.js'; | ||
import isAfter from './date/isAfter.js'; | ||
@@ -18,2 +19,3 @@ import isBefore from './date/isBefore.js'; | ||
import parse from './date/parse.js'; | ||
import set from './date/set.js'; | ||
import startOf from './date/startOf.js'; | ||
@@ -29,2 +31,3 @@ import subtract from './date/subtract.js'; | ||
format, | ||
get, | ||
isAfter, | ||
@@ -39,4 +42,5 @@ isBefore, | ||
parse, | ||
set, | ||
startOf, | ||
subtract | ||
}; |
{ | ||
"name": "celia", | ||
"version": "3.0.1", | ||
"version": "3.0.5", | ||
"description": "A modern JavaScript utility library delivering modularity, performance, & extras.", | ||
@@ -5,0 +5,0 @@ "main": "./celia.common.js", |
@@ -139,3 +139,3 @@ # celia | ||
- finished all method for manipulating DOM | ||
- finished all functions for manipulating DOM | ||
@@ -145,1 +145,5 @@ ### 3.0.1 | ||
- performance optimization | ||
### 3.0.4 | ||
- added `get` and `set` two functions for manipulating Date |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
256828
129
7655
148