@bereasoftware/time-guard 2.7.2 → 2.8.0
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.en.md +5 -1
- package/README.md +5 -1
- package/dist/angular/index.cjs +1 -148
- package/dist/angular/index.es.js +60 -112
- package/dist/calendars/index.cjs +1 -357
- package/dist/calendars/index.es.js +66 -99
- package/dist/chunk-C6qsp3rV.cjs +1 -0
- package/dist/core-Dxn1aRFk.js +1186 -0
- package/dist/core-TqmHKXY1.cjs +1 -0
- package/dist/core.d.ts +27 -1
- package/dist/index.d.ts +4 -2
- package/dist/locales/index.cjs +1 -7
- package/dist/locales/index.d.ts +11 -0
- package/dist/locales/index.es.js +3 -3
- package/dist/{locales-CGdn0DJN.cjs → locales-3Mw99lQ-.js} +201 -82
- package/dist/locales-bc-5kDuZ.cjs +1 -0
- package/dist/native/index.cjs +1 -48
- package/dist/native/index.es.js +8 -18
- package/dist/plugins/advanced-format.cjs +1 -105
- package/dist/plugins/advanced-format.es.js +43 -63
- package/dist/plugins/duration.cjs +1 -258
- package/dist/plugins/duration.es.js +59 -165
- package/dist/plugins/relative-time.cjs +1 -166
- package/dist/plugins/relative-time.es.js +36 -74
- package/dist/qwik/index.cjs +1 -104
- package/dist/qwik/index.es.js +33 -94
- package/dist/react/index.cjs +1 -112
- package/dist/react/index.es.js +57 -91
- package/dist/solid/index.cjs +1 -127
- package/dist/solid/index.es.js +34 -116
- package/dist/svelte/index.cjs +1 -398
- package/dist/svelte/index.es.js +85 -344
- package/dist/time-guard.cjs +3 -7359
- package/dist/time-guard.es.js +3412 -3625
- package/dist/time-guard.iife.js +3 -13549
- package/dist/time-guard.umd.js +3 -13550
- package/dist/vue/index.cjs +1 -143
- package/dist/vue/index.es.js +62 -116
- package/package.json +2 -3
- package/dist/chunk-S8Y6Ng9i.cjs +0 -36
- package/dist/core-BIDjudpO.cjs +0 -1892
- package/dist/core-DWPXk3rz.js +0 -1809
- package/dist/locales-BUE_aq8K.js +0 -3514
package/README.en.md
CHANGED
|
@@ -180,9 +180,13 @@ console.log(inTokyo.format("YYYY-MM-DD HH:mm:ss Z"));
|
|
|
180
180
|
|
|
181
181
|
### 3. Localization
|
|
182
182
|
|
|
183
|
-
Support for 40+ languages and locales:
|
|
183
|
+
Support for 40+ languages and locales. The core only registers `en`/`es` by default — call `loadAllLocales()` once (or register just the ones you use via `/locales`, see [Modular Bundle](#modular-bundle)):
|
|
184
184
|
|
|
185
185
|
```typescript
|
|
186
|
+
import { TimeGuard, loadAllLocales } from "@bereasoftware/time-guard";
|
|
187
|
+
|
|
188
|
+
loadAllLocales(); // once, at app startup
|
|
189
|
+
|
|
186
190
|
const date = TimeGuard.from("2024-03-13");
|
|
187
191
|
|
|
188
192
|
date.locale("en").format("MMMM DD, YYYY"); // March 13, 2024
|
package/README.md
CHANGED
|
@@ -197,9 +197,13 @@ console.log(inTokyo.format('YYYY-MM-DD HH:mm:ss Z'));
|
|
|
197
197
|
|
|
198
198
|
### 3. Localización
|
|
199
199
|
|
|
200
|
-
Soporte para 40+ idiomas y locales:
|
|
200
|
+
Soporte para 40+ idiomas y locales. El core solo trae `en`/`es` registrados; llama `loadAllLocales()` una vez (o registra solo los que uses vía `/locales`, ver [Bundle Modular](#bundle-modular)):
|
|
201
201
|
|
|
202
202
|
```typescript
|
|
203
|
+
import { TimeGuard, loadAllLocales } from '@bereasoftware/time-guard';
|
|
204
|
+
|
|
205
|
+
loadAllLocales(); // una sola vez, al iniciar tu app
|
|
206
|
+
|
|
203
207
|
const date = TimeGuard.from('2024-03-13');
|
|
204
208
|
|
|
205
209
|
date.locale('en').format('MMMM DD, YYYY'); // March 13, 2024
|
package/dist/angular/index.cjs
CHANGED
|
@@ -1,148 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_core = require("../core-BIDjudpO.cjs");
|
|
4
|
-
let _angular_core = require("@angular/core");
|
|
5
|
-
let rxjs = require("rxjs");
|
|
6
|
-
//#region src/angular.ts
|
|
7
|
-
/**
|
|
8
|
-
* Angular Injection Token to register global/default TimeGuard configurations.
|
|
9
|
-
*/
|
|
10
|
-
var TIME_GUARD_CONFIG = new _angular_core.InjectionToken("TIME_GUARD_CONFIG");
|
|
11
|
-
/**
|
|
12
|
-
* Angular Pipe to format a date/time using TimeGuard.
|
|
13
|
-
* Supports global configuration overrides via DI.
|
|
14
|
-
* Usage: `{{ date | timeGuardFormat:'YYYY-MM-DD':'es' }}`
|
|
15
|
-
*/
|
|
16
|
-
var TimeGuardFormatPipe = class {
|
|
17
|
-
globalConfig = (0, _angular_core.inject)(TIME_GUARD_CONFIG, { optional: true });
|
|
18
|
-
transform(value, pattern = "YYYY-MM-DD HH:mm:ss", locale) {
|
|
19
|
-
if (!value) return "";
|
|
20
|
-
try {
|
|
21
|
-
const tg = require_core.TimeGuard.from(value);
|
|
22
|
-
const activeLocale = locale || this.globalConfig?.locale;
|
|
23
|
-
if (activeLocale) return tg.locale(activeLocale).format(pattern);
|
|
24
|
-
return tg.format(pattern);
|
|
25
|
-
} catch {
|
|
26
|
-
return String(value);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Angular Pipe for dynamic relative time humanization.
|
|
32
|
-
* Supports global configuration overrides via DI.
|
|
33
|
-
* Usage: `{{ date | timeGuardRelative:'es':'auto' }}`
|
|
34
|
-
*/
|
|
35
|
-
var TimeGuardRelativePipe = class {
|
|
36
|
-
globalConfig = (0, _angular_core.inject)(TIME_GUARD_CONFIG, { optional: true });
|
|
37
|
-
transform(value, locale, numeric) {
|
|
38
|
-
if (!value) return "";
|
|
39
|
-
try {
|
|
40
|
-
const tg = require_core.TimeGuard.from(value);
|
|
41
|
-
const now = require_core.TimeGuard.now();
|
|
42
|
-
const activeLocale = locale || this.globalConfig?.locale;
|
|
43
|
-
return tg.since(now).humanize({
|
|
44
|
-
locale: activeLocale,
|
|
45
|
-
numeric
|
|
46
|
-
});
|
|
47
|
-
} catch {
|
|
48
|
-
return String(value);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Injectable Service to interact with TimeGuard.
|
|
54
|
-
* Provides a high-performance reactive Observable of the current time
|
|
55
|
-
* running outside Angular zone to optimize change detection ticks.
|
|
56
|
-
* Supports global configuration overrides via DI.
|
|
57
|
-
*/
|
|
58
|
-
var TimeGuardService = class {
|
|
59
|
-
ngZone = (0, _angular_core.inject)(_angular_core.NgZone);
|
|
60
|
-
globalConfig = (0, _angular_core.inject)(TIME_GUARD_CONFIG, { optional: true });
|
|
61
|
-
/**
|
|
62
|
-
* Get an Observable of the current time, ticking on the specified interval.
|
|
63
|
-
*/
|
|
64
|
-
getCurrentTime(intervalMs = 1e3, config) {
|
|
65
|
-
const activeConfig = config ?? this.globalConfig ?? void 0;
|
|
66
|
-
return new rxjs.Observable((subscriber) => {
|
|
67
|
-
return this.ngZone.runOutsideAngular(() => {
|
|
68
|
-
subscriber.next(require_core.TimeGuard.now(activeConfig));
|
|
69
|
-
const intervalId = setInterval(() => {
|
|
70
|
-
this.ngZone.run(() => {
|
|
71
|
-
subscriber.next(require_core.TimeGuard.now(activeConfig));
|
|
72
|
-
});
|
|
73
|
-
}, intervalMs);
|
|
74
|
-
return () => {
|
|
75
|
-
clearInterval(intervalId);
|
|
76
|
-
};
|
|
77
|
-
});
|
|
78
|
-
}).pipe((0, rxjs.shareReplay)(1));
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Angular Pipe to dynamically tick and format dates at a custom interval.
|
|
83
|
-
* Highly optimized, impure pipe utilizing TimeGuardService and ChangeDetectorRef.
|
|
84
|
-
* Usage:
|
|
85
|
-
* - Real-time clock: `{{ 'now' | timeGuardLiveFormat:'HH:mm:ss':1000 }}`
|
|
86
|
-
* - Ticking static date: `{{ date | timeGuardLiveFormat:'YYYY-MM-DD HH:mm:ss':5000 }}`
|
|
87
|
-
*/
|
|
88
|
-
var TimeGuardLiveFormatPipe = class {
|
|
89
|
-
latestValue = "";
|
|
90
|
-
subscription;
|
|
91
|
-
lastInput;
|
|
92
|
-
lastPattern;
|
|
93
|
-
lastInterval;
|
|
94
|
-
lastLocale;
|
|
95
|
-
cdr = (0, _angular_core.inject)(_angular_core.ChangeDetectorRef);
|
|
96
|
-
timeGuardService = (0, _angular_core.inject)(TimeGuardService);
|
|
97
|
-
globalConfig = (0, _angular_core.inject)(TIME_GUARD_CONFIG, { optional: true });
|
|
98
|
-
transform(value, pattern = "YYYY-MM-DD HH:mm:ss", intervalMs = 1e3, locale) {
|
|
99
|
-
if (!value) return "";
|
|
100
|
-
if (value !== this.lastInput || pattern !== this.lastPattern || intervalMs !== this.lastInterval || locale !== this.lastLocale) {
|
|
101
|
-
this.ngOnDestroy();
|
|
102
|
-
this.lastInput = value;
|
|
103
|
-
this.lastPattern = pattern;
|
|
104
|
-
this.lastInterval = intervalMs;
|
|
105
|
-
this.lastLocale = locale;
|
|
106
|
-
const activeLocale = locale || this.globalConfig?.locale;
|
|
107
|
-
if (value === "now") this.subscription = this.timeGuardService.getCurrentTime(intervalMs).subscribe((now) => {
|
|
108
|
-
this.latestValue = activeLocale ? now.locale(activeLocale).format(pattern) : now.format(pattern);
|
|
109
|
-
this.cdr.markForCheck();
|
|
110
|
-
});
|
|
111
|
-
else this.subscription = this.timeGuardService.getCurrentTime(intervalMs).subscribe(() => {
|
|
112
|
-
try {
|
|
113
|
-
const tg = require_core.TimeGuard.from(value);
|
|
114
|
-
this.latestValue = activeLocale ? tg.locale(activeLocale).format(pattern) : tg.format(pattern);
|
|
115
|
-
this.cdr.markForCheck();
|
|
116
|
-
} catch {
|
|
117
|
-
this.latestValue = String(value);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
return this.latestValue;
|
|
122
|
-
}
|
|
123
|
-
ngOnDestroy() {
|
|
124
|
-
if (this.subscription) {
|
|
125
|
-
this.subscription.unsubscribe();
|
|
126
|
-
this.subscription = void 0;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
(0, _angular_core.Pipe)({
|
|
131
|
-
name: "timeGuardFormat",
|
|
132
|
-
pure: true
|
|
133
|
-
})(TimeGuardFormatPipe);
|
|
134
|
-
(0, _angular_core.Pipe)({
|
|
135
|
-
name: "timeGuardRelative",
|
|
136
|
-
pure: false
|
|
137
|
-
})(TimeGuardRelativePipe);
|
|
138
|
-
(0, _angular_core.Injectable)({ providedIn: "root" })(TimeGuardService);
|
|
139
|
-
(0, _angular_core.Pipe)({
|
|
140
|
-
name: "timeGuardLiveFormat",
|
|
141
|
-
pure: false
|
|
142
|
-
})(TimeGuardLiveFormatPipe);
|
|
143
|
-
//#endregion
|
|
144
|
-
exports.TIME_GUARD_CONFIG = TIME_GUARD_CONFIG;
|
|
145
|
-
exports.TimeGuardFormatPipe = TimeGuardFormatPipe;
|
|
146
|
-
exports.TimeGuardLiveFormatPipe = TimeGuardLiveFormatPipe;
|
|
147
|
-
exports.TimeGuardRelativePipe = TimeGuardRelativePipe;
|
|
148
|
-
exports.TimeGuardService = TimeGuardService;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../core-TqmHKXY1.cjs");let t=require("@angular/core"),n=require("rxjs");var r=new t.InjectionToken(`TIME_GUARD_CONFIG`),i=class{globalConfig=(0,t.inject)(r,{optional:!0});transform(t,n=`YYYY-MM-DD HH:mm:ss`,r){if(!t)return``;try{let i=e.i.from(t),a=r||this.globalConfig?.locale;return a?i.locale(a).format(n):i.format(n)}catch{return String(t)}}},a=class{globalConfig=(0,t.inject)(r,{optional:!0});transform(t,n,r){if(!t)return``;try{let i=e.i.from(t),a=e.i.now(),o=n||this.globalConfig?.locale;return i.since(a).humanize({locale:o,numeric:r})}catch{return String(t)}}},o=class{ngZone=(0,t.inject)(t.NgZone);globalConfig=(0,t.inject)(r,{optional:!0});getCurrentTime(t=1e3,r){let i=r??this.globalConfig??void 0;return new n.Observable(n=>this.ngZone.runOutsideAngular(()=>{n.next(e.i.now(i));let r=setInterval(()=>{this.ngZone.run(()=>{n.next(e.i.now(i))})},t);return()=>{clearInterval(r)}})).pipe((0,n.shareReplay)(1))}},s=class{latestValue=``;subscription;lastInput;lastPattern;lastInterval;lastLocale;cdr=(0,t.inject)(t.ChangeDetectorRef);timeGuardService=(0,t.inject)(o);globalConfig=(0,t.inject)(r,{optional:!0});transform(t,n=`YYYY-MM-DD HH:mm:ss`,r=1e3,i){if(!t)return``;if(t!==this.lastInput||n!==this.lastPattern||r!==this.lastInterval||i!==this.lastLocale){this.ngOnDestroy(),this.lastInput=t,this.lastPattern=n,this.lastInterval=r,this.lastLocale=i;let a=i||this.globalConfig?.locale;t===`now`?this.subscription=this.timeGuardService.getCurrentTime(r).subscribe(e=>{this.latestValue=a?e.locale(a).format(n):e.format(n),this.cdr.markForCheck()}):this.subscription=this.timeGuardService.getCurrentTime(r).subscribe(()=>{try{let r=e.i.from(t);this.latestValue=a?r.locale(a).format(n):r.format(n),this.cdr.markForCheck()}catch{this.latestValue=String(t)}})}return this.latestValue}ngOnDestroy(){this.subscription&&=(this.subscription.unsubscribe(),void 0)}};(0,t.Pipe)({name:`timeGuardFormat`,pure:!0})(i),(0,t.Pipe)({name:`timeGuardRelative`,pure:!1})(a),(0,t.Injectable)({providedIn:`root`})(o),(0,t.Pipe)({name:`timeGuardLiveFormat`,pure:!1})(s),exports.TIME_GUARD_CONFIG=r,exports.TimeGuardFormatPipe=i,exports.TimeGuardLiveFormatPipe=s,exports.TimeGuardRelativePipe=a,exports.TimeGuardService=o;
|
package/dist/angular/index.es.js
CHANGED
|
@@ -1,143 +1,91 @@
|
|
|
1
|
-
/*! time-guard v2.
|
|
2
|
-
import {
|
|
3
|
-
import { ChangeDetectorRef, Injectable, InjectionToken, NgZone, Pipe, inject } from "@angular/core";
|
|
4
|
-
import { Observable, shareReplay } from "rxjs";
|
|
1
|
+
/*! time-guard v2.8.0 | (c) 2026 Berea-Soft | MIT License | https://github.com/Berea-Soft/time-guard */
|
|
2
|
+
import { i as e } from "../core-Dxn1aRFk.js";
|
|
3
|
+
import { ChangeDetectorRef as t, Injectable as n, InjectionToken as r, NgZone as i, Pipe as a, inject as o } from "@angular/core";
|
|
4
|
+
import { Observable as s, shareReplay as c } from "rxjs";
|
|
5
5
|
//#region src/angular.ts
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Angular Pipe to format a date/time using TimeGuard.
|
|
12
|
-
* Supports global configuration overrides via DI.
|
|
13
|
-
* Usage: `{{ date | timeGuardFormat:'YYYY-MM-DD':'es' }}`
|
|
14
|
-
*/
|
|
15
|
-
var TimeGuardFormatPipe = class {
|
|
16
|
-
globalConfig = inject(TIME_GUARD_CONFIG, { optional: true });
|
|
17
|
-
transform(value, pattern = "YYYY-MM-DD HH:mm:ss", locale) {
|
|
18
|
-
if (!value) return "";
|
|
6
|
+
var l = new r("TIME_GUARD_CONFIG"), u = class {
|
|
7
|
+
globalConfig = o(l, { optional: !0 });
|
|
8
|
+
transform(t, n = "YYYY-MM-DD HH:mm:ss", r) {
|
|
9
|
+
if (!t) return "";
|
|
19
10
|
try {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (activeLocale) return tg.locale(activeLocale).format(pattern);
|
|
23
|
-
return tg.format(pattern);
|
|
11
|
+
let i = e.from(t), a = r || this.globalConfig?.locale;
|
|
12
|
+
return a ? i.locale(a).format(n) : i.format(n);
|
|
24
13
|
} catch {
|
|
25
|
-
return String(
|
|
14
|
+
return String(t);
|
|
26
15
|
}
|
|
27
16
|
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
* Usage: `{{ date | timeGuardRelative:'es':'auto' }}`
|
|
33
|
-
*/
|
|
34
|
-
var TimeGuardRelativePipe = class {
|
|
35
|
-
globalConfig = inject(TIME_GUARD_CONFIG, { optional: true });
|
|
36
|
-
transform(value, locale, numeric) {
|
|
37
|
-
if (!value) return "";
|
|
17
|
+
}, d = class {
|
|
18
|
+
globalConfig = o(l, { optional: !0 });
|
|
19
|
+
transform(t, n, r) {
|
|
20
|
+
if (!t) return "";
|
|
38
21
|
try {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
locale: activeLocale,
|
|
44
|
-
numeric
|
|
22
|
+
let i = e.from(t), a = e.now(), o = n || this.globalConfig?.locale;
|
|
23
|
+
return i.since(a).humanize({
|
|
24
|
+
locale: o,
|
|
25
|
+
numeric: r
|
|
45
26
|
});
|
|
46
27
|
} catch {
|
|
47
|
-
return String(
|
|
28
|
+
return String(t);
|
|
48
29
|
}
|
|
49
30
|
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return this.ngZone.runOutsideAngular(() => {
|
|
67
|
-
subscriber.next(TimeGuard.now(activeConfig));
|
|
68
|
-
const intervalId = setInterval(() => {
|
|
69
|
-
this.ngZone.run(() => {
|
|
70
|
-
subscriber.next(TimeGuard.now(activeConfig));
|
|
71
|
-
});
|
|
72
|
-
}, intervalMs);
|
|
73
|
-
return () => {
|
|
74
|
-
clearInterval(intervalId);
|
|
75
|
-
};
|
|
76
|
-
});
|
|
77
|
-
}).pipe(shareReplay(1));
|
|
31
|
+
}, f = class {
|
|
32
|
+
ngZone = o(i);
|
|
33
|
+
globalConfig = o(l, { optional: !0 });
|
|
34
|
+
getCurrentTime(t = 1e3, n) {
|
|
35
|
+
let r = n ?? this.globalConfig ?? void 0;
|
|
36
|
+
return new s((n) => this.ngZone.runOutsideAngular(() => {
|
|
37
|
+
n.next(e.now(r));
|
|
38
|
+
let i = setInterval(() => {
|
|
39
|
+
this.ngZone.run(() => {
|
|
40
|
+
n.next(e.now(r));
|
|
41
|
+
});
|
|
42
|
+
}, t);
|
|
43
|
+
return () => {
|
|
44
|
+
clearInterval(i);
|
|
45
|
+
};
|
|
46
|
+
})).pipe(c(1));
|
|
78
47
|
}
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Angular Pipe to dynamically tick and format dates at a custom interval.
|
|
82
|
-
* Highly optimized, impure pipe utilizing TimeGuardService and ChangeDetectorRef.
|
|
83
|
-
* Usage:
|
|
84
|
-
* - Real-time clock: `{{ 'now' | timeGuardLiveFormat:'HH:mm:ss':1000 }}`
|
|
85
|
-
* - Ticking static date: `{{ date | timeGuardLiveFormat:'YYYY-MM-DD HH:mm:ss':5000 }}`
|
|
86
|
-
*/
|
|
87
|
-
var TimeGuardLiveFormatPipe = class {
|
|
48
|
+
}, p = class {
|
|
88
49
|
latestValue = "";
|
|
89
50
|
subscription;
|
|
90
51
|
lastInput;
|
|
91
52
|
lastPattern;
|
|
92
53
|
lastInterval;
|
|
93
54
|
lastLocale;
|
|
94
|
-
cdr =
|
|
95
|
-
timeGuardService =
|
|
96
|
-
globalConfig =
|
|
97
|
-
transform(
|
|
98
|
-
if (!
|
|
99
|
-
if (
|
|
100
|
-
this.ngOnDestroy();
|
|
101
|
-
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
this.
|
|
105
|
-
const activeLocale = locale || this.globalConfig?.locale;
|
|
106
|
-
if (value === "now") this.subscription = this.timeGuardService.getCurrentTime(intervalMs).subscribe((now) => {
|
|
107
|
-
this.latestValue = activeLocale ? now.locale(activeLocale).format(pattern) : now.format(pattern);
|
|
108
|
-
this.cdr.markForCheck();
|
|
109
|
-
});
|
|
110
|
-
else this.subscription = this.timeGuardService.getCurrentTime(intervalMs).subscribe(() => {
|
|
55
|
+
cdr = o(t);
|
|
56
|
+
timeGuardService = o(f);
|
|
57
|
+
globalConfig = o(l, { optional: !0 });
|
|
58
|
+
transform(t, n = "YYYY-MM-DD HH:mm:ss", r = 1e3, i) {
|
|
59
|
+
if (!t) return "";
|
|
60
|
+
if (t !== this.lastInput || n !== this.lastPattern || r !== this.lastInterval || i !== this.lastLocale) {
|
|
61
|
+
this.ngOnDestroy(), this.lastInput = t, this.lastPattern = n, this.lastInterval = r, this.lastLocale = i;
|
|
62
|
+
let a = i || this.globalConfig?.locale;
|
|
63
|
+
t === "now" ? this.subscription = this.timeGuardService.getCurrentTime(r).subscribe((e) => {
|
|
64
|
+
this.latestValue = a ? e.locale(a).format(n) : e.format(n), this.cdr.markForCheck();
|
|
65
|
+
}) : this.subscription = this.timeGuardService.getCurrentTime(r).subscribe(() => {
|
|
111
66
|
try {
|
|
112
|
-
|
|
113
|
-
this.latestValue =
|
|
114
|
-
this.cdr.markForCheck();
|
|
67
|
+
let r = e.from(t);
|
|
68
|
+
this.latestValue = a ? r.locale(a).format(n) : r.format(n), this.cdr.markForCheck();
|
|
115
69
|
} catch {
|
|
116
|
-
this.latestValue = String(
|
|
70
|
+
this.latestValue = String(t);
|
|
117
71
|
}
|
|
118
72
|
});
|
|
119
73
|
}
|
|
120
74
|
return this.latestValue;
|
|
121
75
|
}
|
|
122
76
|
ngOnDestroy() {
|
|
123
|
-
|
|
124
|
-
this.subscription.unsubscribe();
|
|
125
|
-
this.subscription = void 0;
|
|
126
|
-
}
|
|
77
|
+
this.subscription &&= (this.subscription.unsubscribe(), void 0);
|
|
127
78
|
}
|
|
128
79
|
};
|
|
129
|
-
|
|
80
|
+
a({
|
|
130
81
|
name: "timeGuardFormat",
|
|
131
|
-
pure:
|
|
132
|
-
})(
|
|
133
|
-
Pipe({
|
|
82
|
+
pure: !0
|
|
83
|
+
})(u), a({
|
|
134
84
|
name: "timeGuardRelative",
|
|
135
|
-
pure:
|
|
136
|
-
})(
|
|
137
|
-
Injectable({ providedIn: "root" })(TimeGuardService);
|
|
138
|
-
Pipe({
|
|
85
|
+
pure: !1
|
|
86
|
+
})(d), n({ providedIn: "root" })(f), a({
|
|
139
87
|
name: "timeGuardLiveFormat",
|
|
140
|
-
pure:
|
|
141
|
-
})(
|
|
88
|
+
pure: !1
|
|
89
|
+
})(p);
|
|
142
90
|
//#endregion
|
|
143
|
-
export { TIME_GUARD_CONFIG, TimeGuardFormatPipe, TimeGuardLiveFormatPipe, TimeGuardRelativePipe, TimeGuardService };
|
|
91
|
+
export { l as TIME_GUARD_CONFIG, u as TimeGuardFormatPipe, p as TimeGuardLiveFormatPipe, d as TimeGuardRelativePipe, f as TimeGuardService };
|