Comparing version 4.0.0-alpha.0 to 4.0.0-alpha.1
@@ -1,2 +0,2 @@ | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.fecha={})}(this,function(n){"use strict";var t=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,e="[^\\s]+",r=/\[([^]*?)\]/gm;function o(n,t){for(var e=[],r=0,o=n.length;r<o;r++)e.push(n[r].substr(0,t));return e}var u=function(n){return function(t,e){var r=e[n].map(function(n){return n.toLowerCase()}).indexOf(t.toLowerCase());return r>-1?r:null}};function i(n){for(var t=[],e=1;e<arguments.length;e++)t[e-1]=arguments[e];for(var r=0,o=t;r<o.length;r++){var u=o[r];for(var i in u)n[i]=u[i]}return n}var a=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"],s=o(d,3),f={dayNamesShort:o(a,3),dayNames:a,monthNamesShort:s,monthNames:d,amPm:["am","pm"],DoFn:function(n){return n+["th","st","nd","rd"][n%10>3?0:(n-n%10!=10?1:0)*n%10]}},m=i({},f),c=function(n){return n.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},l=function(n,t){for(void 0===t&&(t=2),n=String(n);n.length<t;)n="0"+n;return n},h={D:function(n){return String(n.getDate())},DD:function(n){return l(n.getDate())},Do:function(n,t){return t.DoFn(n.getDate())},d:function(n){return String(n.getDay())},dd:function(n){return l(n.getDay())},ddd:function(n,t){return t.dayNamesShort[n.getDay()]},dddd:function(n,t){return t.dayNames[n.getDay()]},M:function(n){return String(n.getMonth()+1)},MM:function(n){return l(n.getMonth()+1)},MMM:function(n,t){return t.monthNamesShort[n.getMonth()]},MMMM:function(n,t){return t.monthNames[n.getMonth()]},YY:function(n){return l(String(n.getFullYear()),4).substr(2)},YYYY:function(n){return l(n.getFullYear(),4)},h:function(n){return String(n.getHours()%12||12)},hh:function(n){return l(n.getHours()%12||12)},H:function(n){return String(n.getHours())},HH:function(n){return l(n.getHours())},m:function(n){return String(n.getMinutes())},mm:function(n){return l(n.getMinutes())},s:function(n){return String(n.getSeconds())},ss:function(n){return l(n.getSeconds())},S:function(n){return String(Math.round(n.getMilliseconds()/100))},SS:function(n){return l(Math.round(n.getMilliseconds()/10),2)},SSS:function(n){return l(n.getMilliseconds(),3)},a:function(n,t){return n.getHours()<12?t.amPm[0]:t.amPm[1]},A:function(n,t){return n.getHours()<12?t.amPm[0].toUpperCase():t.amPm[1].toUpperCase()},ZZ:function(n){var t=n.getTimezoneOffset();return(t>0?"-":"+")+l(100*Math.floor(Math.abs(t)/60)+Math.abs(t)%60,4)}},g=function(n){return+n-1},M=[null,"[1-9]\\d?"],D=[null,e],y=["isPm",e,function(n,t){var e=n.toLowerCase();return e===t.amPm[0]?0:e===t.amPm[1]?1:null}],p={D:["day","[1-9]\\d?"],DD:["day","\\d\\d"],Do:["day","[1-9]\\d?"+e,function(n){return parseInt(n,10)}],M:["month","[1-9]\\d?",g],MM:["month","\\d\\d",g],YY:["year","\\d\\d",function(n){var t=+(""+(new Date).getFullYear()).substr(0,2);return+(""+(+n>68?t-1:t)+n)}],h:["hour","[1-9]\\d?",void 0,"isPm"],hh:["hour","\\d\\d",void 0,"isPm"],H:["hour","[1-9]\\d?"],HH:["hour","\\d\\d"],m:["minute","[1-9]\\d?"],mm:["minute","\\d\\d"],s:["second","[1-9]\\d?"],ss:["second","\\d\\d"],YYYY:["year","\\d{4}"],S:["millisecond","\\d",function(n){return 100*+n}],SS:["millisecond","\\d\\d",function(n){return 10*+n}],SSS:["millisecond","\\d{3}"],d:M,dd:M,ddd:D,dddd:D,MMM:["month",e,u("monthNamesShort")],MMMM:["month",e,u("monthNames")],a:y,A:y,ZZ:["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(n){var t=(n+"").match(/([+-]|\d\d)/gi);if(t){var e=60*+t[1]+parseInt(t[2],10);return"+"===t[0]?e:-e}return 0}]},S={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"};n.assign=i,n.format=function(n,e,o){if(void 0===e&&(e=S.default),void 0===o&&(o={}),"number"==typeof n&&(n=new Date(n)),"[object Date]"!==Object.prototype.toString.call(n)||isNaN(n.getTime()))throw new Error("Invalid Date pass to format");var u=[];e=(e=S[e]||e).replace(r,function(n,t){return u.push(t),"@@@"});var a=i(i({},m),o);return(e=e.replace(t,function(t){return h[t](n,a)})).replace(/@@@/g,function(){return u.shift()})},n.parse=function(n,e,o){if(void 0===o&&(o={}),"string"!=typeof e)throw new Error("Invalid format in fecha parse");if(e=S[e]||e,n.length>1e3)return null;var u={year:(new Date).getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},a=[],d=[],s=e.replace(r,function(n,t){return d.push(c(t)),"@@@"}),f={},l={};s=c(s).replace(t,function(n){var t=p[n],e=t[0],r=t[1],o=t[3];if(f[e])throw new Error("Invalid format. "+e+" specified twice in format");return f[e]=!0,o&&(l[o]=!0),a.push(t),"("+r+")"}),Object.keys(l).forEach(function(n){if(!f[n])throw new Error("Invalid format. "+n+" is required in specified format")}),s=s.replace(/@@@/g,function(){return d.shift()});var h=n.match(new RegExp(s,"i"));if(!h)return null;for(var g=i(i({},m),o),M=1;M<h.length;M++){var D=a[M-1],y=D[0],Y=D[2],v=Y?Y(h[M],g):+h[M];if(null==v)return null;u[y]=v}1===u.isPm&&null!=u.hour&&12!=+u.hour?u.hour=+u.hour+12:0===u.isPm&&12==+u.hour&&(u.hour=0);for(var H=new Date(u.year,u.month,u.day,u.hour,u.minute,u.second,u.millisecond),b=[["month","getMonth"],["day","getDate"],["hour","getHours"],["minute","getMinutes"],["second","getSeconds"]],w=(M=0,b.length);M<w;M++)if(u[b[M][0]]!==H[b[M][1]]())return null;return null==u.timezoneOffset?H:new Date(Date.UTC(u.year,u.month,u.day,u.hour,u.minute-u.timezoneOffset,u.second,u.millisecond))},n.defaultI18n=f,n.setGlobalDateI18n=function(n){return m=i(m,n)},n.setGlobalDateMasks=function(n){return i(S,n)},Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.fecha={})}(this,function(t){"use strict";var n=/d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g,e="[^\\s]+",r=/\[([^]*?)\]/gm;function o(t,n){for(var e=[],r=0,o=t.length;r<o;r++)e.push(t[r].substr(0,n));return e}var u=function(t){return function(n,e){var r=e[t].map(function(t){return t.toLowerCase()}).indexOf(n.toLowerCase());return r>-1?r:null}};function a(t){for(var n=[],e=1;e<arguments.length;e++)n[e-1]=arguments[e];for(var r=0,o=n;r<o.length;r++){var u=o[r];for(var a in u)t[a]=u[a]}return t}var i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],d=["January","February","March","April","May","June","July","August","September","October","November","December"],s=o(d,3),f={dayNamesShort:o(i,3),dayNames:i,monthNamesShort:s,monthNames:d,amPm:["am","pm"],DoFn:function(t){return t+["th","st","nd","rd"][t%10>3?0:(t-t%10!=10?1:0)*t%10]}},m=a({},f),c=function(t){return m=a(m,t)},l=function(t){return t.replace(/[|\\{()[^$+*?.-]/g,"\\$&")},h=function(t,n){for(void 0===n&&(n=2),t=String(t);t.length<n;)t="0"+t;return t},g={D:function(t){return String(t.getDate())},DD:function(t){return h(t.getDate())},Do:function(t,n){return n.DoFn(t.getDate())},d:function(t){return String(t.getDay())},dd:function(t){return h(t.getDay())},ddd:function(t,n){return n.dayNamesShort[t.getDay()]},dddd:function(t,n){return n.dayNames[t.getDay()]},M:function(t){return String(t.getMonth()+1)},MM:function(t){return h(t.getMonth()+1)},MMM:function(t,n){return n.monthNamesShort[t.getMonth()]},MMMM:function(t,n){return n.monthNames[t.getMonth()]},YY:function(t){return h(String(t.getFullYear()),4).substr(2)},YYYY:function(t){return h(t.getFullYear(),4)},h:function(t){return String(t.getHours()%12||12)},hh:function(t){return h(t.getHours()%12||12)},H:function(t){return String(t.getHours())},HH:function(t){return h(t.getHours())},m:function(t){return String(t.getMinutes())},mm:function(t){return h(t.getMinutes())},s:function(t){return String(t.getSeconds())},ss:function(t){return h(t.getSeconds())},S:function(t){return String(Math.round(t.getMilliseconds()/100))},SS:function(t){return h(Math.round(t.getMilliseconds()/10),2)},SSS:function(t){return h(t.getMilliseconds(),3)},a:function(t,n){return t.getHours()<12?n.amPm[0]:n.amPm[1]},A:function(t,n){return t.getHours()<12?n.amPm[0].toUpperCase():n.amPm[1].toUpperCase()},ZZ:function(t){var n=t.getTimezoneOffset();return(n>0?"-":"+")+h(100*Math.floor(Math.abs(n)/60)+Math.abs(n)%60,4)}},M=function(t){return+t-1},D=[null,"[1-9]\\d?"],p=[null,e],y=["isPm",e,function(t,n){var e=t.toLowerCase();return e===n.amPm[0]?0:e===n.amPm[1]?1:null}],S={D:["day","[1-9]\\d?"],DD:["day","\\d\\d"],Do:["day","[1-9]\\d?"+e,function(t){return parseInt(t,10)}],M:["month","[1-9]\\d?",M],MM:["month","\\d\\d",M],YY:["year","\\d\\d",function(t){var n=+(""+(new Date).getFullYear()).substr(0,2);return+(""+(+t>68?n-1:n)+t)}],h:["hour","[1-9]\\d?",void 0,"isPm"],hh:["hour","\\d\\d",void 0,"isPm"],H:["hour","[1-9]\\d?"],HH:["hour","\\d\\d"],m:["minute","[1-9]\\d?"],mm:["minute","\\d\\d"],s:["second","[1-9]\\d?"],ss:["second","\\d\\d"],YYYY:["year","\\d{4}"],S:["millisecond","\\d",function(t){return 100*+t}],SS:["millisecond","\\d\\d",function(t){return 10*+t}],SSS:["millisecond","\\d{3}"],d:D,dd:D,ddd:p,dddd:p,MMM:["month",e,u("monthNamesShort")],MMMM:["month",e,u("monthNames")],a:y,A:y,ZZ:["timezoneOffset","[^\\s]*?[\\+\\-]\\d\\d:?\\d\\d|[^\\s]*?Z?",function(t){var n=(t+"").match(/([+-]|\d\d)/gi);if(n){var e=60*+n[1]+parseInt(n[2],10);return"+"===n[0]?e:-e}return 0}]},Y={default:"ddd MMM DD YYYY HH:mm:ss",shortDate:"M/D/YY",mediumDate:"MMM D, YYYY",longDate:"MMMM D, YYYY",fullDate:"dddd, MMMM D, YYYY",shortTime:"HH:mm",mediumTime:"HH:mm:ss",longTime:"HH:mm:ss.SSS"},v=function(t){return a(Y,t)},H=function(t,e,o){if(void 0===e&&(e=Y.default),void 0===o&&(o={}),"number"==typeof t&&(t=new Date(t)),"[object Date]"!==Object.prototype.toString.call(t)||isNaN(t.getTime()))throw new Error("Invalid Date pass to format");var u=[];e=(e=Y[e]||e).replace(r,function(t,n){return u.push(n),"@@@"});var i=a(a({},m),o);return(e=e.replace(n,function(n){return g[n](t,i)})).replace(/@@@/g,function(){return u.shift()})};function b(t,e,o){if(void 0===o&&(o={}),"string"!=typeof e)throw new Error("Invalid format in fecha parse");if(e=Y[e]||e,t.length>1e3)return null;var u={year:(new Date).getFullYear(),month:0,day:1,hour:0,minute:0,second:0,millisecond:0,isPm:null,timezoneOffset:null},i=[],d=[],s=e.replace(r,function(t,n){return d.push(l(n)),"@@@"}),f={},c={};s=l(s).replace(n,function(t){var n=S[t],e=n[0],r=n[1],o=n[3];if(f[e])throw new Error("Invalid format. "+e+" specified twice in format");return f[e]=!0,o&&(c[o]=!0),i.push(n),"("+r+")"}),Object.keys(c).forEach(function(t){if(!f[t])throw new Error("Invalid format. "+t+" is required in specified format")}),s=s.replace(/@@@/g,function(){return d.shift()});var h=t.match(new RegExp(s,"i"));if(!h)return null;for(var g=a(a({},m),o),M=1;M<h.length;M++){var D=i[M-1],p=D[0],y=D[2],v=y?y(h[M],g):+h[M];if(null==v)return null;u[p]=v}1===u.isPm&&null!=u.hour&&12!=+u.hour?u.hour=+u.hour+12:0===u.isPm&&12==+u.hour&&(u.hour=0);for(var H=new Date(u.year,u.month,u.day,u.hour,u.minute,u.second,u.millisecond),b=[["month","getMonth"],["day","getDate"],["hour","getHours"],["minute","getMinutes"],["second","getSeconds"]],w=(M=0,b.length);M<w;M++)if(u[b[M][0]]!==H[b[M][1]]())return null;return null==u.timezoneOffset?H:new Date(Date.UTC(u.year,u.month,u.day,u.hour,u.minute-u.timezoneOffset,u.second,u.millisecond))}var w={format:H,parse:b,defaultI18n:f,setGlobalDateI18n:c,setGlobalDateMasks:v};t.assign=a,t.default=w,t.format=H,t.parse=b,t.defaultI18n=f,t.setGlobalDateI18n=c,t.setGlobalDateMasks=v,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=fecha.min.js.map |
@@ -47,2 +47,14 @@ export declare type I18nSettings = { | ||
declare function parse(dateStr: string, format: string, i18n?: I18nSettingsOptional): Date | null; | ||
declare const _default: { | ||
format: (dateObj: Date, mask?: string, i18n?: I18nSettingsOptional) => string; | ||
parse: typeof parse; | ||
defaultI18n: I18nSettings; | ||
setGlobalDateI18n: (i18n: I18nSettingsOptional) => I18nSettings; | ||
setGlobalDateMasks: (masks: { | ||
[key: string]: string; | ||
}) => { | ||
[key: string]: string; | ||
}; | ||
}; | ||
export default _default; | ||
export { format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks }; |
@@ -364,4 +364,8 @@ var token = /d{1,4}|M{1,4}|YY(?:YY)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g; | ||
} | ||
var fecha = { | ||
format: format, parse: parse, defaultI18n: defaultI18n, setGlobalDateI18n: setGlobalDateI18n, setGlobalDateMasks: setGlobalDateMasks | ||
}; | ||
export default fecha; | ||
export { assign, format, parse, defaultI18n, setGlobalDateI18n, setGlobalDateMasks }; | ||
//# sourceMappingURL=fecha.js.map |
@@ -370,4 +370,8 @@ (function (global, factory) { | ||
} | ||
var fecha = { | ||
format: format, parse: parse, defaultI18n: defaultI18n, setGlobalDateI18n: setGlobalDateI18n, setGlobalDateMasks: setGlobalDateMasks | ||
}; | ||
exports.assign = assign; | ||
exports.default = fecha; | ||
exports.format = format; | ||
@@ -374,0 +378,0 @@ exports.parse = parse; |
{ | ||
"name": "fecha", | ||
"version": "4.0.0-alpha.0", | ||
"version": "4.0.0-alpha.1", | ||
"description": "Date formatting and parsing", | ||
@@ -5,0 +5,0 @@ "main": "lib/fecha.umd.js", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
47197
833
0