@jsarc/timez 0.0.0 → 0.0.1-beta.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/index.ts +7 -41
- package/js/index.js +2 -24
- package/package.json +1 -1
- package/web/timez.js +2 -16
- package/web/timez.min.js +1 -1
package/README.md
CHANGED
|
@@ -56,7 +56,7 @@ const { Timez } = require('@jsarc/timez');
|
|
|
56
56
|
```html
|
|
57
57
|
<script src="@jsarc/timez/timez.all.js"></script>
|
|
58
58
|
<script>
|
|
59
|
-
// Disponible globalement comme window.Timez
|
|
59
|
+
// Disponible globalement comme (window as any).Timez
|
|
60
60
|
const now = Timez.now();
|
|
61
61
|
console.log(now.format('EUROPEAN'));
|
|
62
62
|
</script>
|
package/index.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
|
|
3
|
-
interface Window {
|
|
4
|
-
default: typeof defaultElementGF;
|
|
5
|
-
Timez: any;
|
|
6
|
-
__bundledModules: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
3
|
interface TimezFormatOptions {
|
|
10
4
|
strict?: boolean;
|
|
11
5
|
timezone?: string;
|
|
@@ -24,9 +18,9 @@ interface ParseResult {
|
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
|
|
27
|
-
type TimezInput = Date | string | number | Timez | undefined;
|
|
21
|
+
type TimezInput = Date | string | number | typeof Timez | undefined;
|
|
28
22
|
|
|
29
|
-
const globalFunct = (function(
|
|
23
|
+
const globalFunct = (function() {
|
|
30
24
|
'use strict';
|
|
31
25
|
|
|
32
26
|
|
|
@@ -34,8 +28,6 @@ const globalFunct = (function(global: any) {
|
|
|
34
28
|
|
|
35
29
|
|
|
36
30
|
|
|
37
|
-
|
|
38
|
-
|
|
39
31
|
class Timez {
|
|
40
32
|
private _date?: Date;
|
|
41
33
|
private static readonly FORMAT_TOKENS: { [key: string]: (timez: Timez) => string | undefined } = {
|
|
@@ -328,12 +320,12 @@ const globalFunct = (function(global: any) {
|
|
|
328
320
|
const endIncluded = inclusivity[1] === ']';
|
|
329
321
|
|
|
330
322
|
const afterStart = startIncluded ?
|
|
331
|
-
this.isSame(startTimez) || this.isAfter(startTimez) :
|
|
332
|
-
this.isAfter(startTimez);
|
|
323
|
+
this.isSame(startTimez as any) || this.isAfter(startTimez as any) :
|
|
324
|
+
this.isAfter(startTimez as any);
|
|
333
325
|
|
|
334
326
|
const beforeEnd = endIncluded ?
|
|
335
|
-
this.isSame(endTimez) || this.isBefore(endTimez) :
|
|
336
|
-
this.isBefore(endTimez);
|
|
327
|
+
this.isSame(endTimez as any) || this.isBefore(endTimez as any) :
|
|
328
|
+
this.isBefore(endTimez as any);
|
|
337
329
|
|
|
338
330
|
return afterStart && beforeEnd;
|
|
339
331
|
}
|
|
@@ -877,16 +869,6 @@ const globalFunct = (function(global: any) {
|
|
|
877
869
|
static get FORMATS() {
|
|
878
870
|
return { ...Timez.PREDEFINED_FORMATS };
|
|
879
871
|
}
|
|
880
|
-
|
|
881
|
-
static exposeToGlobal(): void {
|
|
882
|
-
if (typeof window !== 'undefined') {
|
|
883
|
-
window.Timez = Timez;
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
if (typeof window !== 'undefined') {
|
|
889
|
-
window.Timez = Timez;
|
|
890
872
|
}
|
|
891
873
|
|
|
892
874
|
|
|
@@ -900,29 +882,13 @@ const globalFunct = (function(global: any) {
|
|
|
900
882
|
|
|
901
883
|
const __bundledModules = globalFunctModule;
|
|
902
884
|
|
|
903
|
-
if (typeof global !== 'undefined') {
|
|
904
|
-
(global as any).default = Timez;
|
|
905
|
-
(global as any).Timez = Timez;
|
|
906
|
-
(global as any).__bundledModules = __bundledModules;
|
|
907
|
-
}
|
|
908
|
-
|
|
909
|
-
if (typeof window !== "undefined") {
|
|
910
|
-
(window as any).default = Timez;
|
|
911
|
-
(window as any).Timez = Timez;
|
|
912
|
-
(window as any).__bundledModules = __bundledModules;
|
|
913
|
-
}
|
|
914
|
-
|
|
915
885
|
if (typeof exports !== 'undefined') {
|
|
916
886
|
exports.default = Timez;
|
|
917
887
|
exports.Timez = Timez;
|
|
918
888
|
}
|
|
919
889
|
return globalFunctModule;
|
|
920
890
|
|
|
921
|
-
})(
|
|
922
|
-
typeof window !== 'undefined' ? window :
|
|
923
|
-
typeof self !== 'undefined' ? self :
|
|
924
|
-
typeof globalThis !== 'undefined' ? globalThis :
|
|
925
|
-
{});
|
|
891
|
+
})();
|
|
926
892
|
|
|
927
893
|
type TimezElementTypeGF = typeof globalFunct.Timez;
|
|
928
894
|
|
package/js/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const globalFunct = (function (
|
|
1
|
+
const globalFunct = (function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
class Timez {
|
|
4
4
|
_date;
|
|
@@ -702,40 +702,18 @@ const globalFunct = (function (global) {
|
|
|
702
702
|
static get FORMATS() {
|
|
703
703
|
return { ...Timez.PREDEFINED_FORMATS };
|
|
704
704
|
}
|
|
705
|
-
static exposeToGlobal() {
|
|
706
|
-
if (typeof window !== 'undefined') {
|
|
707
|
-
window.Timez = Timez;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
if (typeof window !== 'undefined') {
|
|
712
|
-
window.Timez = Timez;
|
|
713
705
|
}
|
|
714
706
|
const globalFunctModule = {
|
|
715
707
|
default: Timez,
|
|
716
708
|
Timez: Timez,
|
|
717
709
|
};
|
|
718
710
|
const __bundledModules = globalFunctModule;
|
|
719
|
-
if (typeof global !== 'undefined') {
|
|
720
|
-
global.default = Timez;
|
|
721
|
-
global.Timez = Timez;
|
|
722
|
-
global.__bundledModules = __bundledModules;
|
|
723
|
-
}
|
|
724
|
-
if (typeof window !== "undefined") {
|
|
725
|
-
window.default = Timez;
|
|
726
|
-
window.Timez = Timez;
|
|
727
|
-
window.__bundledModules = __bundledModules;
|
|
728
|
-
}
|
|
729
711
|
if (typeof exports !== 'undefined') {
|
|
730
712
|
exports.default = Timez;
|
|
731
713
|
exports.Timez = Timez;
|
|
732
714
|
}
|
|
733
715
|
return globalFunctModule;
|
|
734
|
-
})(
|
|
735
|
-
typeof window !== 'undefined' ? window :
|
|
736
|
-
typeof self !== 'undefined' ? self :
|
|
737
|
-
typeof globalThis !== 'undefined' ? globalThis :
|
|
738
|
-
{});
|
|
716
|
+
})();
|
|
739
717
|
const TimezElementGF = globalFunct.Timez;
|
|
740
718
|
const defaultElementGF = globalFunct.default;
|
|
741
719
|
export { defaultElementGF as default, TimezElementGF as Timez, };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.0.0",
|
|
6
|
+
"version": "0.0.1-beta.0.2",
|
|
7
7
|
"description": "Timez est une bibliothèque JavaScript/TypeScript puissante et intuitive pour la manipulation des dates et fuseaux horaires. Inspirée par les meilleures pratiques de Python et Moment.js, elle offre une API fluide et type-safe pour tous vos besoins de gestion temporelle.",
|
|
8
8
|
"main": "index.ts",
|
|
9
9
|
"keywords": [],
|
package/web/timez.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const globalFunct = (function (
|
|
1
|
+
const globalFunct = (function () {
|
|
2
2
|
'use strict';
|
|
3
3
|
class Timez {
|
|
4
4
|
_date;
|
|
@@ -716,25 +716,11 @@ const globalFunct = (function (global) {
|
|
|
716
716
|
Timez: Timez,
|
|
717
717
|
};
|
|
718
718
|
const __bundledModules = globalFunctModule;
|
|
719
|
-
if (typeof global !== 'undefined') {
|
|
720
|
-
global.default = Timez;
|
|
721
|
-
global.Timez = Timez;
|
|
722
|
-
global.__bundledModules = __bundledModules;
|
|
723
|
-
}
|
|
724
|
-
if (typeof window !== "undefined") {
|
|
725
|
-
window.default = Timez;
|
|
726
|
-
window.Timez = Timez;
|
|
727
|
-
window.__bundledModules = __bundledModules;
|
|
728
|
-
}
|
|
729
719
|
if (typeof exports !== 'undefined') {
|
|
730
720
|
exports.default = Timez;
|
|
731
721
|
exports.Timez = Timez;
|
|
732
722
|
}
|
|
733
723
|
return globalFunctModule;
|
|
734
|
-
})(
|
|
735
|
-
typeof window !== 'undefined' ? window :
|
|
736
|
-
typeof self !== 'undefined' ? self :
|
|
737
|
-
typeof globalThis !== 'undefined' ? globalThis :
|
|
738
|
-
{});
|
|
724
|
+
})();
|
|
739
725
|
const TimezElementGF = globalFunct.Timez;
|
|
740
726
|
const defaultElementGF = globalFunct.default;
|
package/web/timez.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
let globalFunct=(e=>{class l{_date;static FORMAT_TOKENS={"%Y":e=>e.year()?.toString().padStart(4,"0"),"%y":e=>e.year()?.toString().slice(-2).padStart(2,"0"),"%m":e=>e.month()?.toString().padStart(2,"0"),"%d":e=>e.date()?.toString().padStart(2,"0"),"%H":e=>e.hour()?.toString().padStart(2,"0"),"%M":e=>e.minute()?.toString().padStart(2,"0"),"%S":e=>e.second()?.toString().padStart(2,"0"),"%f":e=>e.millisecond()?.toString().padStart(3,"0"),"%z":e=>{e=e.utcOffset();if(e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+(Math.abs(e)%60).toString().padStart(2,"0")},"%s":e=>{e=e.valueOf();return e?Math.floor(e/1e3).toString():void 0}};static PREDEFINED_FORMATS={ISO:"%Y-%m-%dT%H:%M:%S.%fZ",ISO_DATE:"%Y-%m-%d",ISO_TIME:"%H:%M:%S.%fZ",COMPACT:"%Y%m%d%H%M%S",SLASH_DATETIME:"%Y/%m/%d %H:%M:%S.%fZ",SLASH_DATETIME_SEC:"%Y/%m/%d %H:%M:%S",SLASH_DATETIME_MIN:"%Y/%m/%d %H:%M",EUROPEAN:"%d/%m/%Y %H:%M:%S GMT%z",SLASH_DATE:"%Y/%m/%d",TIME_MICRO:"%H:%M:%S.%fZ",TIME_SEC:"%H:%M:%S",CUSTOM_GREETING:"[Bonjour celestin, ][la date actuelle est:: le] %d/%m/%Y [à] %H:%M:%S.%f[Z]"};constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof l&&e&&e?._date?this._date=new Date(e?._date):e instanceof Date?this._date=new Date(e):"string"==typeof e?this._date=l.parseString(e,t):"number"==typeof e?this._date=new Date(e):null==e||"number"==typeof e&&isNaN(e)?this._date=new Date:this._date=void 0}static now(){return new l}static parse(e,t){return"string"==typeof t&&0<t.length&&(e instanceof l&&e&&e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e))&&l.parseWithFormat(e,t)||new l(e)}static unix(e){return new l(1e3*e)}static utc(){var e=new Date;return new l(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()))}year(){return this._date?.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){return this._date?.getDate()}hour(){return this._date?.getHours()}minute(){return this._date?.getMinutes()}second(){return this._date?.getSeconds()}millisecond(){return this._date?.getMilliseconds()}day(){return this._date?.getDay()}add(e,t){if(!this._date)return new l(void 0);var a=new Date(this._date);switch(t){case"years":a.setFullYear(a.getFullYear()+e);break;case"months":a.setMonth(a.getMonth()+e);break;case"days":a.setDate(a.getDate()+e);break;case"hours":a.setHours(a.getHours()+e);break;case"minutes":a.setMinutes(a.getMinutes()+e);break;case"seconds":a.setSeconds(a.getSeconds()+e);break;case"milliseconds":a.setMilliseconds(a.getMilliseconds()+e)}return new l(a)}subtract(e,t){return this.add(-e,t)}startOf(e){if(!this._date)return new l(void 0);var t=new Date(this._date);switch(e){case"year":t.setMonth(0,1),t.setHours(0,0,0,0);break;case"month":t.setDate(1),t.setHours(0,0,0,0);break;case"day":t.setHours(0,0,0,0);break;case"hour":t.setMinutes(0,0,0);break;case"minute":t.setSeconds(0,0);break;case"second":t.setMilliseconds(0)}return new l(t)}endOf(e){var t=this.startOf(e);switch(e){case"year":return t.add(1,"years").subtract(1,"milliseconds");case"month":return t.add(1,"months").subtract(1,"milliseconds");case"day":return t.add(1,"days").subtract(1,"milliseconds");case"hour":return t.add(1,"hours").subtract(1,"milliseconds");case"minute":return t.add(1,"minutes").subtract(1,"milliseconds");case"second":return t.add(1,"seconds").subtract(1,"milliseconds");default:return t}}isBefore(e,t="()"){t="]"===t[1],e=e instanceof l?e:new l(e);return!(!this._date||!e._date)&&(!t&&this._date<e._date||!!t&&this._date<=e._date)}isAfter(e,t="()"){t="["===t[0],e=e instanceof l?e:new l(e);return!(!this._date||!e._date)&&(!t&&this._date>e._date||!!t&&this._date>=e._date)}isSame(e,t){var a,e=e instanceof l?e:new l(e);return!t&&this._date&&e._date?this._date.getTime()===e._date.getTime():(a=t?this.startOf(t):void 0,e=t?e.startOf(t):void 0,!!(a&&a?._date&&e&&e?._date)&&a._date.getTime()===e._date.getTime())}isBetween(e,t,a="()"){var e=e instanceof l?e:new l(e),t=t instanceof l?t:new l(t),i="["===a[0],a="]"===a[1],i=i&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return i&&e}format(e){if(!e)return this.toISOString();var t,a,i=l.PREDEFINED_FORMATS[e];if(i)return this.format(i);let r="",n=0;for(;n<e.length;)"["===e[n]?-1===(a=e.indexOf("]",n))?(r+=e[n],n++):(t=e.substring(n+1,a),r+=t,n=a+1):"%"===e[n]&&n+1<e.length?(t="%"+e[n+1],a=l.FORMAT_TOKENS[t],r+=a?a(this):t,n+=2):(r+=e[n],n++);return r}setTimezone(e){var t;return this._date?(t=this._date.getTimezoneOffset(),e=this.parseTimezoneOffset(e),e=new Date(this._date.getTime()+6e4*(e-t)),new l(e)):new l(void 0)}utc(){return this._date?new l(new Date(Date.UTC(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds()))):new l(void 0)}local(){return this._date?new l(new Date(this._date.getFullYear(),this._date.getMonth(),this._date.getDate(),this._date.getHours(),this._date.getMinutes(),this._date.getSeconds(),this._date.getMilliseconds())):new l(void 0)}toString(){return this._date?.toString()}toISOString(){return this._date?.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){return this._date?.getTime()}unix(){return this._date?Math.floor(this._date.getTime()/1e3):void 0}utcOffset(){return this._date?-this._date.getTimezoneOffset():void 0}isCorrect(){return!!this._date&&!isNaN(this._date.getTime())}timezone(){if(this._date)try{return(new Intl.DateTimeFormat).resolvedOptions().timeZone||void 0}catch(e){return this.timezoneFromOffset()}}timezoneAbbr(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneNameFromOffset()}}timezoneOffsetString(){var e=this.utcOffset();if(void 0!==e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+":"+(Math.abs(e)%60).toString().padStart(2,"0")}dateChecker(e){return e instanceof l&&!!e&&!!e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e)}timezoneFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Etc/UTC",60:"Europe/Paris",120:"Europe/Athens",180:"Europe/Moscow",240:"Asia/Dubai",270:"Asia/Tehran",300:"Asia/Karachi",330:"Asia/Kolkata",345:"Asia/Rangoon",360:"Asia/Dhaka",390:"Asia/Yangon",420:"Asia/Bangkok",480:"Asia/Shanghai",525:"Asia/Kathmandu",540:"Asia/Tokyo",570:"Australia/Adelaide",600:"Australia/Sydney",630:"Australia/Lord_Howe",660:"Pacific/Noumea",675:"Australia/Eucla",720:"Pacific/Auckland",780:"Pacific/Chatham","-60":"Atlantic/Azores","-120":"America/Noronha","-180":"America/Argentina/Buenos_Aires","-210":"America/St_Johns","-240":"America/Halifax","-270":"America/Caracas","-300":"America/New_York","-360":"America/Chicago","-420":"America/Denver","-480":"America/Los_Angeles","-540":"America/Anchorage","-600":"Pacific/Honolulu","-660":"Pacific/Pago_Pago","-720":"Pacific/Kiritimati"}[e]||"Etc/GMT"+(0<=e?"-":"+")+Math.abs(e)/60}timezoneAbbrFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"GMT",60:"CET","-300":"EST","-360":"CST","-420":"MST","-480":"PST"}[e]||"GMT"+(0<=e?"+":"")+e/60}timezoneNameFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Greenwich Mean Time",60:"Central European Time","-300":"Eastern Standard Time","-360":"Central Standard Time","-420":"Mountain Standard Time","-480":"Pacific Standard Time"}[e]||"GMT"+(0<=e?"+":"")+e/60}isDST(){if(this._date)try{var e=new Date(this._date.getFullYear(),0,1),t=new Date(this._date.getFullYear(),6,1),a=Math.max(e.getTimezoneOffset(),t.getTimezoneOffset());return this._date.getTimezoneOffset()<a}catch(e){}}static parseString(e,t=!1){var a=new Date(e);if(!isNaN(a.getTime()))return a;var i,r=[/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z$/,/^(\d{4})-(\d{2})-(\d{2})$/,/^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/];for(i of r){var n=e.match(i);if(n){n=n.slice(1).map(Number);if(i===r[0])return new Date(Date.UTC(n[0],n[1]-1,n[2],n[3],n[4],n[5],n[6]));if(i===r[1])return new Date(n[0],n[1]-1,n[2]);if(i===r[2])return new Date(n[0],n[1]-1,n[2],n[3],n[4],n[5]);if(i===r[3])return new Date(n[0],n[1]-1,n[2],n[3],n[4],n[5])}}a=new Date(e);if(!isNaN(a.getTime()))return a;if(t)throw new Error("Unable to parse date string: "+e)}static parseWithFormat(e,r){if(e&&r){var n=String(e).trim();if(n){var s={Y:{regex:/\d{4}/,extract:e=>parseInt(e,10)},y:{regex:/\d{2}/,extract:e=>{e=parseInt(e,10);return 70<=e?1900+e:2e3+e}},m:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},d:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},H:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},M:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},S:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},f:{regex:/\d{1,3}/,extract:e=>parseInt(e,10)}},d={year:(new Date).getFullYear(),month:1,day:1,hour:0,minute:0,second:0,millisecond:0};let e=0,t=0,a=!1,i="";for(;t<r.length&&e<n.length;){var o=r[t];if("["===o)a=!0,i="",t++;else if("]"===o&&a){if(n.substring(e,e+i.length)!==i)return;e+=i.length,a=!1,i="",t++}else if(a)i+=o,t++;else if("%"===o&&t+1<r.length){var u=r[t+1],c=s[u];if(c){var h=n.substring(e).match(c.regex);if(!h||0!==h.index)return;var h=h[0],f=c.extract(h);switch(u){case"Y":case"y":d.year=f;break;case"m":d.month=f;break;case"d":d.day=f;break;case"H":d.hour=f;break;case"M":d.minute=f;break;case"S":d.second=f;break;case"f":d.millisecond=f}e+=h.length}else e++;t+=2}else{if(o!==n[e])return;e++,t++}}if(!(d.month<1||12<d.month||d.day<1||31<d.day||d.hour<0||23<d.hour||d.minute<0||59<d.minute||d.second<0||59<d.second||d.millisecond<0||999<d.millisecond))try{var m=new Date(d.year,d.month-1,d.day,d.hour,d.minute,d.second,d.millisecond);if(!isNaN(m.getTime()))return new l(m)}catch(e){}}}}static getTokenLength(e){return{Y:4,y:2,m:2,d:2,H:2,M:2,S:2,f:3,z:5}[e]||1}parseTimezoneOffset(e){var t={UTC:0,EST:-300,EDT:-240,CST:-360,CDT:-300,PST:-480,PDT:-420};return void 0!==t[e.toUpperCase()]?t[e.toUpperCase()]:(t=e.match(/^([+-])(\d{1,2}):?(\d{2})?$/))?("+"===t[1]?1:-1)*(60*parseInt(t[2],10)+(t[3]?parseInt(t[3],10):0)):this._date?-this._date.getTimezoneOffset():0}static get FORMATS(){return{...l.PREDEFINED_FORMATS}}static exposeToGlobal(){"undefined"!=typeof window&&(window.Timez=l)}}"undefined"!=typeof window&&(window.Timez=l);var t={default:l,Timez:l},a=t;return void 0!==e&&(e.default=l,e.Timez=l,e.__bundledModules=a),"undefined"!=typeof window&&(window.default=l,window.Timez=l,window.__bundledModules=a),"undefined"!=typeof exports&&(exports.default=l,exports.Timez=l),t})("undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof globalThis?globalThis:{}),TimezElementGF=globalFunct.Timez,defaultElementGF=globalFunct.default;
|
|
1
|
+
let globalFunct=(()=>{class l{_date;static FORMAT_TOKENS={"%Y":e=>e.year()?.toString().padStart(4,"0"),"%y":e=>e.year()?.toString().slice(-2).padStart(2,"0"),"%m":e=>e.month()?.toString().padStart(2,"0"),"%d":e=>e.date()?.toString().padStart(2,"0"),"%H":e=>e.hour()?.toString().padStart(2,"0"),"%M":e=>e.minute()?.toString().padStart(2,"0"),"%S":e=>e.second()?.toString().padStart(2,"0"),"%f":e=>e.millisecond()?.toString().padStart(3,"0"),"%z":e=>{e=e.utcOffset();if(e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+(Math.abs(e)%60).toString().padStart(2,"0")},"%s":e=>{e=e.valueOf();return e?Math.floor(e/1e3).toString():void 0}};static PREDEFINED_FORMATS={ISO:"%Y-%m-%dT%H:%M:%S.%fZ",ISO_DATE:"%Y-%m-%d",ISO_TIME:"%H:%M:%S.%fZ",COMPACT:"%Y%m%d%H%M%S",SLASH_DATETIME:"%Y/%m/%d %H:%M:%S.%fZ",SLASH_DATETIME_SEC:"%Y/%m/%d %H:%M:%S",SLASH_DATETIME_MIN:"%Y/%m/%d %H:%M",EUROPEAN:"%d/%m/%Y %H:%M:%S GMT%z",SLASH_DATE:"%Y/%m/%d",TIME_MICRO:"%H:%M:%S.%fZ",TIME_SEC:"%H:%M:%S",CUSTOM_GREETING:"[Bonjour celestin, ][la date actuelle est:: le] %d/%m/%Y [à] %H:%M:%S.%f[Z]"};constructor(e,t=!1){!1===this.dateChecker(e)?this._date=void 0:e instanceof l&&e&&e?._date?this._date=new Date(e?._date):e instanceof Date?this._date=new Date(e):"string"==typeof e?this._date=l.parseString(e,t):"number"==typeof e?this._date=new Date(e):null==e||"number"==typeof e&&isNaN(e)?this._date=new Date:this._date=void 0}static now(){return new l}static parse(e,t){return"string"==typeof t&&0<t.length&&(e instanceof l&&e&&e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e))&&l.parseWithFormat(e,t)||new l(e)}static unix(e){return new l(1e3*e)}static utc(){var e=new Date;return new l(Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()))}year(){return this._date?.getFullYear()}month(){return this._date?this._date.getMonth()+1:void 0}date(){return this._date?.getDate()}hour(){return this._date?.getHours()}minute(){return this._date?.getMinutes()}second(){return this._date?.getSeconds()}millisecond(){return this._date?.getMilliseconds()}day(){return this._date?.getDay()}add(e,t){if(!this._date)return new l(void 0);var a=new Date(this._date);switch(t){case"years":a.setFullYear(a.getFullYear()+e);break;case"months":a.setMonth(a.getMonth()+e);break;case"days":a.setDate(a.getDate()+e);break;case"hours":a.setHours(a.getHours()+e);break;case"minutes":a.setMinutes(a.getMinutes()+e);break;case"seconds":a.setSeconds(a.getSeconds()+e);break;case"milliseconds":a.setMilliseconds(a.getMilliseconds()+e)}return new l(a)}subtract(e,t){return this.add(-e,t)}startOf(e){if(!this._date)return new l(void 0);var t=new Date(this._date);switch(e){case"year":t.setMonth(0,1),t.setHours(0,0,0,0);break;case"month":t.setDate(1),t.setHours(0,0,0,0);break;case"day":t.setHours(0,0,0,0);break;case"hour":t.setMinutes(0,0,0);break;case"minute":t.setSeconds(0,0);break;case"second":t.setMilliseconds(0)}return new l(t)}endOf(e){var t=this.startOf(e);switch(e){case"year":return t.add(1,"years").subtract(1,"milliseconds");case"month":return t.add(1,"months").subtract(1,"milliseconds");case"day":return t.add(1,"days").subtract(1,"milliseconds");case"hour":return t.add(1,"hours").subtract(1,"milliseconds");case"minute":return t.add(1,"minutes").subtract(1,"milliseconds");case"second":return t.add(1,"seconds").subtract(1,"milliseconds");default:return t}}isBefore(e,t="()"){t="]"===t[1],e=e instanceof l?e:new l(e);return!(!this._date||!e._date)&&(!t&&this._date<e._date||!!t&&this._date<=e._date)}isAfter(e,t="()"){t="["===t[0],e=e instanceof l?e:new l(e);return!(!this._date||!e._date)&&(!t&&this._date>e._date||!!t&&this._date>=e._date)}isSame(e,t){var a,e=e instanceof l?e:new l(e);return!t&&this._date&&e._date?this._date.getTime()===e._date.getTime():(a=t?this.startOf(t):void 0,e=t?e.startOf(t):void 0,!!(a&&a?._date&&e&&e?._date)&&a._date.getTime()===e._date.getTime())}isBetween(e,t,a="()"){var e=e instanceof l?e:new l(e),t=t instanceof l?t:new l(t),r="["===a[0],a="]"===a[1],r=r&&this.isSame(e)||this.isAfter(e),e=a&&this.isSame(t)||this.isBefore(t);return r&&e}format(e){if(!e)return this.toISOString();var t,a,r=l.PREDEFINED_FORMATS[e];if(r)return this.format(r);let i="",s=0;for(;s<e.length;)"["===e[s]?-1===(a=e.indexOf("]",s))?(i+=e[s],s++):(t=e.substring(s+1,a),i+=t,s=a+1):"%"===e[s]&&s+1<e.length?(t="%"+e[s+1],a=l.FORMAT_TOKENS[t],i+=a?a(this):t,s+=2):(i+=e[s],s++);return i}setTimezone(e){var t;return this._date?(t=this._date.getTimezoneOffset(),e=this.parseTimezoneOffset(e),e=new Date(this._date.getTime()+6e4*(e-t)),new l(e)):new l(void 0)}utc(){return this._date?new l(new Date(Date.UTC(this._date.getUTCFullYear(),this._date.getUTCMonth(),this._date.getUTCDate(),this._date.getUTCHours(),this._date.getUTCMinutes(),this._date.getUTCSeconds(),this._date.getUTCMilliseconds()))):new l(void 0)}local(){return this._date?new l(new Date(this._date.getFullYear(),this._date.getMonth(),this._date.getDate(),this._date.getHours(),this._date.getMinutes(),this._date.getSeconds(),this._date.getMilliseconds())):new l(void 0)}toString(){return this._date?.toString()}toISOString(){return this._date?.toISOString()}toDate(){return this._date?new Date(this._date):void 0}valueOf(){return this._date?.getTime()}unix(){return this._date?Math.floor(this._date.getTime()/1e3):void 0}utcOffset(){return this._date?-this._date.getTimezoneOffset():void 0}isCorrect(){return!!this._date&&!isNaN(this._date.getTime())}timezone(){if(this._date)try{return(new Intl.DateTimeFormat).resolvedOptions().timeZone||void 0}catch(e){return this.timezoneFromOffset()}}timezoneAbbr(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneAbbrFromOffset()}}timezoneName(){if(this._date)try{return new Intl.DateTimeFormat("en",{timeZoneName:"long"}).formatToParts(this._date).find(e=>"timeZoneName"===e.type)?.value||void 0}catch(e){return this.timezoneNameFromOffset()}}timezoneOffsetString(){var e=this.utcOffset();if(void 0!==e)return(0<=e?"+":"-")+Math.floor(Math.abs(e)/60).toString().padStart(2,"0")+":"+(Math.abs(e)%60).toString().padStart(2,"0")}dateChecker(e){return e instanceof l&&!!e&&!!e?._date||e instanceof Date||"string"==typeof e||"number"==typeof e||null==e||"number"==typeof e&&isNaN(e)}timezoneFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Etc/UTC",60:"Europe/Paris",120:"Europe/Athens",180:"Europe/Moscow",240:"Asia/Dubai",270:"Asia/Tehran",300:"Asia/Karachi",330:"Asia/Kolkata",345:"Asia/Rangoon",360:"Asia/Dhaka",390:"Asia/Yangon",420:"Asia/Bangkok",480:"Asia/Shanghai",525:"Asia/Kathmandu",540:"Asia/Tokyo",570:"Australia/Adelaide",600:"Australia/Sydney",630:"Australia/Lord_Howe",660:"Pacific/Noumea",675:"Australia/Eucla",720:"Pacific/Auckland",780:"Pacific/Chatham","-60":"Atlantic/Azores","-120":"America/Noronha","-180":"America/Argentina/Buenos_Aires","-210":"America/St_Johns","-240":"America/Halifax","-270":"America/Caracas","-300":"America/New_York","-360":"America/Chicago","-420":"America/Denver","-480":"America/Los_Angeles","-540":"America/Anchorage","-600":"Pacific/Honolulu","-660":"Pacific/Pago_Pago","-720":"Pacific/Kiritimati"}[e]||"Etc/GMT"+(0<=e?"-":"+")+Math.abs(e)/60}timezoneAbbrFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"GMT",60:"CET","-300":"EST","-360":"CST","-420":"MST","-480":"PST"}[e]||"GMT"+(0<=e?"+":"")+e/60}timezoneNameFromOffset(){var e=this.utcOffset();if(void 0!==e)return{0:"Greenwich Mean Time",60:"Central European Time","-300":"Eastern Standard Time","-360":"Central Standard Time","-420":"Mountain Standard Time","-480":"Pacific Standard Time"}[e]||"GMT"+(0<=e?"+":"")+e/60}isDST(){if(this._date)try{var e=new Date(this._date.getFullYear(),0,1),t=new Date(this._date.getFullYear(),6,1),a=Math.max(e.getTimezoneOffset(),t.getTimezoneOffset());return this._date.getTimezoneOffset()<a}catch(e){}}static parseString(e,t=!1){var a=new Date(e);if(!isNaN(a.getTime()))return a;var r,i=[/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})\.(\d{3})Z$/,/^(\d{4})-(\d{2})-(\d{2})$/,/^(\d{4})\/(\d{2})\/(\d{2}) (\d{2}):(\d{2}):(\d{2})$/,/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/];for(r of i){var s=e.match(r);if(s){s=s.slice(1).map(Number);if(r===i[0])return new Date(Date.UTC(s[0],s[1]-1,s[2],s[3],s[4],s[5],s[6]));if(r===i[1])return new Date(s[0],s[1]-1,s[2]);if(r===i[2])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5]);if(r===i[3])return new Date(s[0],s[1]-1,s[2],s[3],s[4],s[5])}}a=new Date(e);if(!isNaN(a.getTime()))return a;if(t)throw new Error("Unable to parse date string: "+e)}static parseWithFormat(e,i){if(e&&i){var s=String(e).trim();if(s){var n={Y:{regex:/\d{4}/,extract:e=>parseInt(e,10)},y:{regex:/\d{2}/,extract:e=>{e=parseInt(e,10);return 70<=e?1900+e:2e3+e}},m:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},d:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},H:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},M:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},S:{regex:/\d{1,2}/,extract:e=>parseInt(e,10)},f:{regex:/\d{1,3}/,extract:e=>parseInt(e,10)}},d={year:(new Date).getFullYear(),month:1,day:1,hour:0,minute:0,second:0,millisecond:0};let e=0,t=0,a=!1,r="";for(;t<i.length&&e<s.length;){var o=i[t];if("["===o)a=!0,r="",t++;else if("]"===o&&a){if(s.substring(e,e+r.length)!==r)return;e+=r.length,a=!1,r="",t++}else if(a)r+=o,t++;else if("%"===o&&t+1<i.length){var u=i[t+1],c=n[u];if(c){var h=s.substring(e).match(c.regex);if(!h||0!==h.index)return;var h=h[0],m=c.extract(h);switch(u){case"Y":case"y":d.year=m;break;case"m":d.month=m;break;case"d":d.day=m;break;case"H":d.hour=m;break;case"M":d.minute=m;break;case"S":d.second=m;break;case"f":d.millisecond=m}e+=h.length}else e++;t+=2}else{if(o!==s[e])return;e++,t++}}if(!(d.month<1||12<d.month||d.day<1||31<d.day||d.hour<0||23<d.hour||d.minute<0||59<d.minute||d.second<0||59<d.second||d.millisecond<0||999<d.millisecond))try{var f=new Date(d.year,d.month-1,d.day,d.hour,d.minute,d.second,d.millisecond);if(!isNaN(f.getTime()))return new l(f)}catch(e){}}}}static getTokenLength(e){return{Y:4,y:2,m:2,d:2,H:2,M:2,S:2,f:3,z:5}[e]||1}parseTimezoneOffset(e){var t={UTC:0,EST:-300,EDT:-240,CST:-360,CDT:-300,PST:-480,PDT:-420};return void 0!==t[e.toUpperCase()]?t[e.toUpperCase()]:(t=e.match(/^([+-])(\d{1,2}):?(\d{2})?$/))?("+"===t[1]?1:-1)*(60*parseInt(t[2],10)+(t[3]?parseInt(t[3],10):0)):this._date?-this._date.getTimezoneOffset():0}static get FORMATS(){return{...l.PREDEFINED_FORMATS}}static exposeToGlobal(){"undefined"!=typeof window&&(window.Timez=l)}}"undefined"!=typeof window&&(window.Timez=l);var e={default:l,Timez:l};return"undefined"!=typeof exports&&(exports.default=l,exports.Timez=l),e})(),TimezElementGF=globalFunct.Timez,defaultElementGF=globalFunct.default;
|