wsp-ms-core 1.1.18 → 1.1.21
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/dist/index.cjs +28 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime as DateTime$1 } from 'luxon';
|
|
1
2
|
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
3
|
import { Pool, RowDataPacket, PoolConnection } from 'mysql2/promise';
|
|
3
4
|
|
|
@@ -66,7 +67,7 @@ declare class DateTime extends ValueObject<string> {
|
|
|
66
67
|
toPrimitives(): Record<string, unknown>;
|
|
67
68
|
setTimeZone(timeZone: string, options?: any): DateTime;
|
|
68
69
|
formatInTimezone(timezone: string): string;
|
|
69
|
-
static create(input?: string | number): DateTime;
|
|
70
|
+
static create(input?: string | number | Date | DateTime$1 | null, format?: string): DateTime;
|
|
70
71
|
static now(): DateTime;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -274,6 +275,7 @@ declare class Country extends ValueObject<string> {
|
|
|
274
275
|
uuid(): string;
|
|
275
276
|
phoneCode(): string;
|
|
276
277
|
url(): string;
|
|
278
|
+
getTimezone(): string;
|
|
277
279
|
static findCountryByAlpha2(alpha2: string): Country;
|
|
278
280
|
static findCountryByUUID(uuid: string): Country;
|
|
279
281
|
static create(country: string): Country;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DateTime as DateTime$1 } from 'luxon';
|
|
1
2
|
import { RequestHandler, ErrorRequestHandler } from 'express';
|
|
2
3
|
import { Pool, RowDataPacket, PoolConnection } from 'mysql2/promise';
|
|
3
4
|
|
|
@@ -66,7 +67,7 @@ declare class DateTime extends ValueObject<string> {
|
|
|
66
67
|
toPrimitives(): Record<string, unknown>;
|
|
67
68
|
setTimeZone(timeZone: string, options?: any): DateTime;
|
|
68
69
|
formatInTimezone(timezone: string): string;
|
|
69
|
-
static create(input?: string | number): DateTime;
|
|
70
|
+
static create(input?: string | number | Date | DateTime$1 | null, format?: string): DateTime;
|
|
70
71
|
static now(): DateTime;
|
|
71
72
|
}
|
|
72
73
|
|
|
@@ -274,6 +275,7 @@ declare class Country extends ValueObject<string> {
|
|
|
274
275
|
uuid(): string;
|
|
275
276
|
phoneCode(): string;
|
|
276
277
|
url(): string;
|
|
278
|
+
getTimezone(): string;
|
|
277
279
|
static findCountryByAlpha2(alpha2: string): Country;
|
|
278
280
|
static findCountryByUUID(uuid: string): Country;
|
|
279
281
|
static create(country: string): Country;
|
package/dist/index.js
CHANGED
|
@@ -189,15 +189,25 @@ var _DateTime = class _DateTime extends ValueObject {
|
|
|
189
189
|
}
|
|
190
190
|
return zoned.toFormat(_DateTime.DEFAULT_FORMAT);
|
|
191
191
|
}
|
|
192
|
-
static create(input) {
|
|
193
|
-
if (input === void 0) {
|
|
192
|
+
static create(input, format = _DateTime.FORMAT) {
|
|
193
|
+
if (input === void 0 || input === null) {
|
|
194
194
|
return new _DateTime(_DateTime.toUtcFormat(LuxonDateTime.now()));
|
|
195
195
|
}
|
|
196
|
+
if (input instanceof LuxonDateTime) {
|
|
197
|
+
return new _DateTime(_DateTime.toUtcFormat(input));
|
|
198
|
+
}
|
|
199
|
+
if (input instanceof Date) {
|
|
200
|
+
return new _DateTime(_DateTime.toUtcFormat(LuxonDateTime.fromJSDate(input, { zone: "utc" })));
|
|
201
|
+
}
|
|
196
202
|
if (typeof input === "number") {
|
|
197
203
|
return new _DateTime(
|
|
198
204
|
_DateTime.toUtcFormat(LuxonDateTime.fromMillis(input, { zone: "utc" }))
|
|
199
205
|
);
|
|
200
206
|
}
|
|
207
|
+
const fromDefault = LuxonDateTime.fromFormat(input, _DateTime.DEFAULT_FORMAT, { zone: "utc" });
|
|
208
|
+
if (fromDefault.isValid) {
|
|
209
|
+
return new _DateTime(input);
|
|
210
|
+
}
|
|
201
211
|
const iso = LuxonDateTime.fromISO(input, { zone: "utc" });
|
|
202
212
|
if (iso.isValid) {
|
|
203
213
|
return new _DateTime(_DateTime.toUtcFormat(iso));
|
|
@@ -701,6 +711,22 @@ var _Country = class _Country extends ValueObject {
|
|
|
701
711
|
url() {
|
|
702
712
|
return this._url;
|
|
703
713
|
}
|
|
714
|
+
getTimezone() {
|
|
715
|
+
const timezones = {
|
|
716
|
+
"URUGUAY": "America/Montevideo",
|
|
717
|
+
"ARGENTINA": "America/Argentina/Buenos_Aires",
|
|
718
|
+
"CHILE": "America/Santiago",
|
|
719
|
+
"BRASIL": "America/Sao_Paulo",
|
|
720
|
+
"COLOMBIA": "America/Bogota",
|
|
721
|
+
"PERU": "America/Lima",
|
|
722
|
+
"ECUADOR": "America/Guayaquil",
|
|
723
|
+
"PARAGUAY": "America/Asuncion",
|
|
724
|
+
"BOLIVIA": "America/La_Paz",
|
|
725
|
+
"VENEZUELA": "America/Caracas",
|
|
726
|
+
"USA": "America/New_York"
|
|
727
|
+
};
|
|
728
|
+
return timezones[this.value] || "utc";
|
|
729
|
+
}
|
|
704
730
|
static findCountryByAlpha2(alpha2) {
|
|
705
731
|
for (const [country, codes] of Object.entries(_Country.COUNTRIES)) {
|
|
706
732
|
if (codes.alpha2 === alpha2.toUpperCase()) {
|