disacomp-dateservice 1.0.7 → 1.0.8

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 CHANGED
@@ -21,6 +21,7 @@ interface IDateManipulator {
21
21
  startDate: string;
22
22
  endDate: string;
23
23
  };
24
+ validateDateIsBetweenPeriods(start: string, end: string, date: string): boolean;
24
25
  }
25
26
  declare class DateService {
26
27
  private dateManipulator;
@@ -42,6 +43,7 @@ declare class DateService {
42
43
  startDate: string;
43
44
  endDate: string;
44
45
  };
46
+ validateDateIsBetweenPeriods(start: string, end: string, date: string): boolean;
45
47
  }
46
48
  declare const DisacompDateService: DateService;
47
49
  export default DisacompDateService;
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dateClarionToSQL = exports.bothDatesFormated = void 0;
3
+ exports.bothDatesFormated = bothDatesFormated;
4
+ exports.dateClarionToSQL = dateClarionToSQL;
4
5
  function AddCeroAtBegin(numero) {
5
6
  return numero < 10 ? `0${numero}` : numero;
6
7
  }
@@ -23,7 +24,6 @@ function bothDatesFormated(dateToFormat) {
23
24
  normalDate: `${day}-${month}-${year}`,
24
25
  };
25
26
  }
26
- exports.bothDatesFormated = bothDatesFormated;
27
27
  function dateClarionToSQL(clarionDate) {
28
28
  let response;
29
29
  if (clarionDate <= 0) {
@@ -35,7 +35,6 @@ function dateClarionToSQL(clarionDate) {
35
35
  }
36
36
  return response.toISOString();
37
37
  }
38
- exports.dateClarionToSQL = dateClarionToSQL;
39
38
  class DateHelper {
40
39
  static isLeapYear(year) {
41
40
  return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
@@ -147,6 +146,15 @@ class DateManipulator {
147
146
  const endDate = `${this.addCeroAtBegin(DateHelper.getDaysInMonth(month, year))}-${this.addCeroAtBegin(month)}-${year}`;
148
147
  return { startDate, endDate };
149
148
  }
149
+ validateDateIsBetweenPeriods(start, end, date) {
150
+ const [startMonth, startYear] = start.split("-").map(Number);
151
+ const startDate = new Date(startYear, startMonth - 1, 1);
152
+ const [endMonth, endYear] = end.split("-").map(Number);
153
+ const endDate = new Date(endYear, endMonth, 0);
154
+ const [day, month, year] = date.split("-").map(Number);
155
+ const targetDate = new Date(year, month - 1, day);
156
+ return targetDate >= startDate && targetDate <= endDate;
157
+ }
150
158
  }
151
159
  class DateService {
152
160
  constructor(dateManipulator) {
@@ -185,6 +193,9 @@ class DateService {
185
193
  getStartAndEndDateOfMonthWithYear(month, year) {
186
194
  return this.dateManipulator.getStartAndEndDateOfMonthWithYear(month, year);
187
195
  }
196
+ validateDateIsBetweenPeriods(start, end, date) {
197
+ return this.dateManipulator.validateDateIsBetweenPeriods(start, end, date);
198
+ }
188
199
  }
189
200
  const DisacompDateService = new DateService(new DateManipulator());
190
201
  exports.default = DisacompDateService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disacomp-dateservice",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Disacomp Date Service",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -56,6 +56,11 @@ interface IDateManipulator {
56
56
  startDate: string;
57
57
  endDate: string;
58
58
  };
59
+ validateDateIsBetweenPeriods(
60
+ start: string, // mm-yyyy
61
+ end: string, // mm-yyyy
62
+ date: string // dd-mm-yyyy
63
+ ): boolean;
59
64
  }
60
65
 
61
66
  // Helper class to handle leap years and days in months
@@ -219,6 +224,26 @@ class DateManipulator implements IDateManipulator {
219
224
  )}-${this.addCeroAtBegin(month)}-${year}`;
220
225
  return { startDate, endDate };
221
226
  }
227
+
228
+ public validateDateIsBetweenPeriods(
229
+ start: string, // mm-yyyy
230
+ end: string, // mm-yyyy
231
+ date: string // dd-mm-yyyy
232
+ ): boolean {
233
+ // Parse start (mm-yyyy) → primer día del mes
234
+ const [startMonth, startYear] = start.split("-").map(Number);
235
+ const startDate = new Date(startYear, startMonth - 1, 1);
236
+
237
+ // Parse end (mm-yyyy) → último día del mes
238
+ const [endMonth, endYear] = end.split("-").map(Number);
239
+ const endDate = new Date(endYear, endMonth, 0); // día 0 = último día del mes anterior
240
+
241
+ // Parse date (dd-mm-yyyy)
242
+ const [day, month, year] = date.split("-").map(Number);
243
+ const targetDate = new Date(year, month - 1, day);
244
+
245
+ return targetDate >= startDate && targetDate <= endDate;
246
+ }
222
247
  }
223
248
 
224
249
  // Client code using dependency inversion
@@ -281,6 +306,14 @@ class DateService {
281
306
  } {
282
307
  return this.dateManipulator.getStartAndEndDateOfMonthWithYear(month, year);
283
308
  }
309
+
310
+ public validateDateIsBetweenPeriods(
311
+ start: string, // mm-yyyy
312
+ end: string, // mm-yyyy
313
+ date: string // dd-mm-yyyy
314
+ ): boolean {
315
+ return this.dateManipulator.validateDateIsBetweenPeriods(start, end, date);
316
+ }
284
317
  }
285
318
  const DisacompDateService = new DateService(new DateManipulator());
286
319
 
@@ -1 +1 @@
1
- {"program":{"fileNames":["../../../../../usr/local/lib/node_modules/typescript/lib/lib.es5.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2016.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.dom.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.scripthost.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.decorators.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2017.full.d.ts","./src/index.ts"],"fileInfos":[{"version":"f59215c5f1d886b05395ee7aca73e0ac69ddfad2843aa88530e797879d511bad","affectsGlobalScope":true},"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","dc48272d7c333ccf58034c0026162576b7d50ea0e69c3b9292f803fc20720fd5","27147504487dc1159369da4f4da8a26406364624fa9bc3db632f7d94a5bae2c3",{"version":"3dda5344576193a4ae48b8d03f105c86f20b2f2aff0a1d1fd7935f5d68649654","affectsGlobalScope":true},{"version":"35299ae4a62086698444a5aaee27fc7aa377c68cbb90b441c9ace246ffd05c97","affectsGlobalScope":true},{"version":"c5c5565225fce2ede835725a92a28ece149f83542aa4866cfb10290bff7b8996","affectsGlobalScope":true},{"version":"7d2dbc2a0250400af0809b0ad5f84686e84c73526de931f84560e483eb16b03c","affectsGlobalScope":true},{"version":"9d9885c728913c1d16e0d2831b40341d6ad9a0ceecaabc55209b306ad9c736a5","affectsGlobalScope":true},{"version":"17bea081b9c0541f39dd1ae9bc8c78bdd561879a682e60e2f25f688c0ecab248","affectsGlobalScope":true},{"version":"4443e68b35f3332f753eacc66a04ac1d2053b8b035a0e0ac1d455392b5e243b3","affectsGlobalScope":true},{"version":"ab22100fdd0d24cfc2cc59d0a00fc8cf449830d9c4030dc54390a46bd562e929","affectsGlobalScope":true},{"version":"f7bd636ae3a4623c503359ada74510c4005df5b36de7f23e1db8a5c543fd176b","affectsGlobalScope":true},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true},{"version":"0c20f4d2358eb679e4ae8a4432bdd96c857a2960fd6800b21ec4008ec59d60ea","affectsGlobalScope":true},{"version":"36ae84ccc0633f7c0787bc6108386c8b773e95d3b052d9464a99cd9b8795fbec","affectsGlobalScope":true},{"version":"82d0d8e269b9eeac02c3bd1c9e884e85d483fcb2cd168bccd6bc54df663da031","affectsGlobalScope":true},{"version":"b8deab98702588840be73d67f02412a2d45a417a3c097b2e96f7f3a42ac483d1","affectsGlobalScope":true},{"version":"4738f2420687fd85629c9efb470793bb753709c2379e5f85bc1815d875ceadcd","affectsGlobalScope":true},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true},{"version":"376d554d042fb409cb55b5cbaf0b2b4b7e669619493c5d18d5fa8bd67273f82a","affectsGlobalScope":true},{"version":"9fc46429fbe091ac5ad2608c657201eb68b6f1b8341bd6d670047d32ed0a88fa","affectsGlobalScope":true},{"version":"189c0703923150aa30673fa3de411346d727cc44a11c75d05d7cf9ef095daa22","affectsGlobalScope":true},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true},"994c234848afc14a2586b6565777f4c0b05dc479ede0a041bfd5becf6dceb586",{"version":"bf2216bf2c0cfbbddbd2eaeeb3455f2e5f8a5d9d2110eff6a10180fbeafa5560","signature":"957b4fced453b84ca46d98b55a9ba37f98840e351b21c18f6d4d4b72753a89b7"}],"root":[27],"options":{"composite":true,"module":1,"noImplicitAny":true,"noImplicitThis":true,"outDir":"./dist","removeComments":true,"rootDir":"./src","strict":true,"strictNullChecks":true,"target":4},"referencedMap":[],"exportedModulesMap":[],"semanticDiagnosticsPerFile":[27,24,25,5,6,10,9,2,11,12,13,14,15,16,17,18,3,4,26,22,19,20,21,23,1,8,7],"latestChangedDtsFile":"./dist/index.d.ts"},"version":"5.1.6"}
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":"f73c9ce6370f9ca3de8f7e803eabaa71cac2e75703e6c19e6ba2726821c11fb8","signature":"b1ecc19de7f20c1cb8dd8547e92e090de3bddd9ef4e918dde889ea577594f1bf"}],"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"}