@carlosdiazz/lottodiz-shared 1.9.3 → 1.9.4
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as joi from "joi";
|
|
1
2
|
/**
|
|
2
3
|
* Convierte una hora entre zonas horarias con soporte DST y límites entre 00:00:00 y 23:59:00
|
|
3
4
|
* @param time - Hora base en formato "HH:mm:ss"
|
|
@@ -6,3 +7,4 @@
|
|
|
6
7
|
* @returns Nueva hora en formato "HH:mm:ss"
|
|
7
8
|
*/
|
|
8
9
|
export declare function convertTimeZone(time: string, timeZone: string, timeZoneChange: string): string;
|
|
10
|
+
export declare const timeZoneValidator: (value: string, helpers: joi.CustomHelpers) => string | joi.ErrorReport;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timeZoneValidator = void 0;
|
|
3
4
|
exports.convertTimeZone = convertTimeZone;
|
|
4
5
|
const luxon_1 = require("luxon");
|
|
5
6
|
/**
|
|
@@ -38,3 +39,13 @@ function convertTimeZone(time, timeZone, timeZoneChange) {
|
|
|
38
39
|
const pad = (n) => n.toString().padStart(2, "0");
|
|
39
40
|
return `${pad(hh)}:${pad(mm)}:${pad(ss)}`;
|
|
40
41
|
}
|
|
42
|
+
const timeZoneValidator = (value, helpers) => {
|
|
43
|
+
const valid = luxon_1.DateTime.local().setZone(value).isValid;
|
|
44
|
+
if (!valid) {
|
|
45
|
+
return helpers.error("any.invalid", {
|
|
46
|
+
message: `"${value}" is not a valid IANA timezone`,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return value;
|
|
50
|
+
};
|
|
51
|
+
exports.timeZoneValidator = timeZoneValidator;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carlosdiazz/lottodiz-shared",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.4",
|
|
4
4
|
"description": "Shared Dtos, models, constants and utils",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"dayjs": "^1.11.18",
|
|
22
|
+
"joi": "^18.0.1",
|
|
22
23
|
"luxon": "^3.7.2"
|
|
23
24
|
}
|
|
24
25
|
}
|