disacomp-dateservice 1.0.12 → 1.0.13
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.d.ts +2 -0
- package/dist/index.js +12 -0
- package/package.json +1 -1
- package/src/index.ts +21 -0
- package/tsconfig.tsbuildinfo +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ interface IDateManipulator {
|
|
|
25
25
|
addMonths(month: number, addMonthsCount: number): number;
|
|
26
26
|
substractMonths(month: number, substractMonthsCount: number): number;
|
|
27
27
|
getListOfDatesBetweenTwoDates(start: string, end: string, includeStartEnd: boolean): string[];
|
|
28
|
+
dateStringToMs(dateStr: string): number;
|
|
28
29
|
}
|
|
29
30
|
declare class DateService {
|
|
30
31
|
private dateManipulator;
|
|
@@ -50,6 +51,7 @@ declare class DateService {
|
|
|
50
51
|
addMonths(month: number, addMonthsCount: number): number;
|
|
51
52
|
substractMonths(month: number, substractMonthsCount: number): number;
|
|
52
53
|
getListOfDatesBetweenTwoDates(start: string, end: string, includeStartEnd: boolean): string[];
|
|
54
|
+
dateStringToMs(dateStr: string): number;
|
|
53
55
|
}
|
|
54
56
|
declare const DisacompDateService: DateService;
|
|
55
57
|
export default DisacompDateService;
|
package/dist/index.js
CHANGED
|
@@ -191,6 +191,15 @@ class DateManipulator {
|
|
|
191
191
|
}
|
|
192
192
|
return result;
|
|
193
193
|
}
|
|
194
|
+
dateStringToMs(dateStr) {
|
|
195
|
+
const [day, month, year] = dateStr.split("-").map(Number);
|
|
196
|
+
if (!day || !month || !year) {
|
|
197
|
+
throw new Error("Formato inválido, usa dd-mm-yyyy");
|
|
198
|
+
}
|
|
199
|
+
const utcMs = Date.UTC(year, month - 1, day, 0, 0, 0);
|
|
200
|
+
const offsetMs = 4 * 60 * 60 * 1000;
|
|
201
|
+
return utcMs + offsetMs;
|
|
202
|
+
}
|
|
194
203
|
}
|
|
195
204
|
class DateService {
|
|
196
205
|
constructor(dateManipulator) {
|
|
@@ -241,6 +250,9 @@ class DateService {
|
|
|
241
250
|
getListOfDatesBetweenTwoDates(start, end, includeStartEnd) {
|
|
242
251
|
return this.dateManipulator.getListOfDatesBetweenTwoDates(start, end, includeStartEnd);
|
|
243
252
|
}
|
|
253
|
+
dateStringToMs(dateStr) {
|
|
254
|
+
return this.dateManipulator.dateStringToMs(dateStr);
|
|
255
|
+
}
|
|
244
256
|
}
|
|
245
257
|
const DisacompDateService = new DateService(new DateManipulator());
|
|
246
258
|
exports.default = DisacompDateService;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ interface IDateManipulator {
|
|
|
68
68
|
end: string,
|
|
69
69
|
includeStartEnd: boolean,
|
|
70
70
|
): string[];
|
|
71
|
+
dateStringToMs(dateStr: string): number;
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
// Helper class to handle leap years and days in months
|
|
@@ -305,6 +306,22 @@ class DateManipulator implements IDateManipulator {
|
|
|
305
306
|
|
|
306
307
|
return result;
|
|
307
308
|
}
|
|
309
|
+
|
|
310
|
+
dateStringToMs(dateStr: string): number {
|
|
311
|
+
const [day, month, year] = dateStr.split("-").map(Number);
|
|
312
|
+
|
|
313
|
+
if (!day || !month || !year) {
|
|
314
|
+
throw new Error("Formato inválido, usa dd-mm-yyyy");
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Creamos la fecha como si fuera UTC
|
|
318
|
+
const utcMs = Date.UTC(year, month - 1, day, 0, 0, 0);
|
|
319
|
+
|
|
320
|
+
// Ajustamos a UTC-4 → sumamos 4 horas para llevarlo a UTC real
|
|
321
|
+
const offsetMs = 4 * 60 * 60 * 1000;
|
|
322
|
+
|
|
323
|
+
return utcMs + offsetMs;
|
|
324
|
+
}
|
|
308
325
|
}
|
|
309
326
|
|
|
310
327
|
// Client code using dependency inversion
|
|
@@ -395,6 +412,10 @@ class DateService {
|
|
|
395
412
|
includeStartEnd,
|
|
396
413
|
);
|
|
397
414
|
}
|
|
415
|
+
|
|
416
|
+
public dateStringToMs(dateStr: string): number {
|
|
417
|
+
return this.dateManipulator.dateStringToMs(dateStr);
|
|
418
|
+
}
|
|
398
419
|
}
|
|
399
420
|
const DisacompDateService = new DateService(new DateManipulator());
|
|
400
421
|
|
package/tsconfig.tsbuildinfo
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"fileNames":["../../../.npm-global/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.scripthost.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.decorators.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.full.d.ts","./src/index.ts"],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1d242d5c24cf285c88bc4fb93c5ff903de8319064e282986edeb6247ba028d5e","impliedFormat":1},{"version":"
|
|
1
|
+
{"fileNames":["../../../.npm-global/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.scripthost.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.decorators.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../.npm-global/lib/node_modules/typescript/lib/lib.es2017.full.d.ts","./src/index.ts"],"fileInfos":[{"version":"c430d44666289dae81f30fa7b2edebf186ecc91a2d4c71266ea6ae76388792e1","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"080941d9f9ff9307f7e27a83bcd888b7c8270716c39af943532438932ec1d0b9","affectsGlobalScope":true,"impliedFormat":1},{"version":"2e80ee7a49e8ac312cc11b77f1475804bee36b3b2bc896bead8b6e1266befb43","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"fb0f136d372979348d59b3f5020b4cdb81b5504192b1cacff5d1fbba29378aa1","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"a680117f487a4d2f30ea46f1b4b7f58bef1480456e18ba53ee85c2746eeca012","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"1d242d5c24cf285c88bc4fb93c5ff903de8319064e282986edeb6247ba028d5e","impliedFormat":1},{"version":"c33f0a0d5174c75c1d3525849ca64992857a4b23600c5644c1609dda17399d47","signature":"9bf06f933970df7042d62d37147f4a7f23e70c08bf7c14a99c537756622eaadd"}],"root":[30],"options":{"composite":true,"module":1,"noImplicitAny":true,"noImplicitThis":true,"outDir":"./dist","removeComments":true,"rootDir":"./src","strict":true,"strictNullChecks":true,"target":4},"latestChangedDtsFile":"./dist/index.d.ts","version":"5.9.3"}
|