disacomp-dateservice 1.0.3 → 1.0.5

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
@@ -12,6 +12,15 @@ interface IDateManipulator {
12
12
  isValidDate(date: string): boolean;
13
13
  getSignDate(): string;
14
14
  getISODateStringFromString(date: string): string;
15
+ getCurrentYear(): number;
16
+ getStartAndEndDateOfMonth(month: number): {
17
+ startDate: string;
18
+ endDate: string;
19
+ };
20
+ getStartAndEndDateOfMonthWithYear(month: number, year: number): {
21
+ startDate: string;
22
+ endDate: string;
23
+ };
15
24
  }
16
25
  declare class DateService {
17
26
  private dateManipulator;
@@ -24,6 +33,15 @@ declare class DateService {
24
33
  isValidDate(dateString: string): boolean;
25
34
  getSignDate(): string;
26
35
  getISODateStringFromString(date: string): string;
36
+ getCurrentYear(): number;
37
+ getStartAndEndDateOfMonth(month: number): {
38
+ startDate: string;
39
+ endDate: string;
40
+ };
41
+ getStartAndEndDateOfMonthWithYear(month: number, year: number): {
42
+ startDate: string;
43
+ endDate: string;
44
+ };
27
45
  }
28
46
  declare const DisacompDateService: DateService;
29
47
  export default DisacompDateService;
package/dist/index.js CHANGED
@@ -132,6 +132,20 @@ class DateManipulator {
132
132
  const [day, month, year] = date.split("-").map(Number);
133
133
  return `${year}-${this.addCeroAtBegin(month)}-${this.addCeroAtBegin(day)}`;
134
134
  }
135
+ getCurrentYear() {
136
+ return new Date().getUTCFullYear();
137
+ }
138
+ getStartAndEndDateOfMonth(month) {
139
+ const year = this.getCurrentYear();
140
+ const startDate = `01-${this.addCeroAtBegin(month)}-${year}`;
141
+ const endDate = `${DateHelper.getDaysInMonth(month, year)}-${this.addCeroAtBegin(month)}-${year}`;
142
+ return { startDate, endDate };
143
+ }
144
+ getStartAndEndDateOfMonthWithYear(month, year) {
145
+ const startDate = `01-${this.addCeroAtBegin(month)}-${year}`;
146
+ const endDate = `${DateHelper.getDaysInMonth(month, year)}-${this.addCeroAtBegin(month)}-${year}`;
147
+ return { startDate, endDate };
148
+ }
135
149
  }
136
150
  class DateService {
137
151
  constructor(dateManipulator) {
@@ -161,6 +175,15 @@ class DateService {
161
175
  getISODateStringFromString(date) {
162
176
  return this.dateManipulator.getISODateStringFromString(date);
163
177
  }
178
+ getCurrentYear() {
179
+ return this.dateManipulator.getCurrentYear();
180
+ }
181
+ getStartAndEndDateOfMonth(month) {
182
+ return this.dateManipulator.getStartAndEndDateOfMonth(month);
183
+ }
184
+ getStartAndEndDateOfMonthWithYear(month, year) {
185
+ return this.dateManipulator.getStartAndEndDateOfMonthWithYear(month, year);
186
+ }
164
187
  }
165
188
  const DisacompDateService = new DateService(new DateManipulator());
166
189
  exports.default = DisacompDateService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disacomp-dateservice",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Disacomp Date Service",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -44,6 +44,18 @@ interface IDateManipulator {
44
44
  isValidDate(date: string): boolean;
45
45
  getSignDate(): string;
46
46
  getISODateStringFromString(date: string): string;
47
+ getCurrentYear(): number;
48
+ getStartAndEndDateOfMonth(month: number): {
49
+ startDate: string;
50
+ endDate: string;
51
+ };
52
+ getStartAndEndDateOfMonthWithYear(
53
+ month: number,
54
+ year: number
55
+ ): {
56
+ startDate: string;
57
+ endDate: string;
58
+ };
47
59
  }
48
60
 
49
61
  // Helper class to handle leap years and days in months
@@ -133,7 +145,7 @@ class DateManipulator implements IDateManipulator {
133
145
  public getPeriodFromDate(date: string): string {
134
146
  const [day, month, year] = date.split("-").map(Number);
135
147
 
136
- return `${month}-${year}`; // Concatenate year and month
148
+ return `${month}-${year}`;
137
149
  }
138
150
 
139
151
  public isValidDate(date: string): boolean {
@@ -175,6 +187,38 @@ class DateManipulator implements IDateManipulator {
175
187
 
176
188
  return `${year}-${this.addCeroAtBegin(month)}-${this.addCeroAtBegin(day)}`; // Formato ISO YYYY-MM-DD
177
189
  }
190
+
191
+ public getCurrentYear(): number {
192
+ return new Date().getUTCFullYear();
193
+ }
194
+
195
+ public getStartAndEndDateOfMonth(month: number): {
196
+ startDate: string;
197
+ endDate: string;
198
+ } {
199
+ const year = this.getCurrentYear();
200
+ const startDate = `01-${this.addCeroAtBegin(month)}-${year}`;
201
+ const endDate = `${DateHelper.getDaysInMonth(
202
+ month,
203
+ year
204
+ )}-${this.addCeroAtBegin(month)}-${year}`;
205
+ return { startDate, endDate };
206
+ }
207
+
208
+ public getStartAndEndDateOfMonthWithYear(
209
+ month: number,
210
+ year: number
211
+ ): {
212
+ startDate: string;
213
+ endDate: string;
214
+ } {
215
+ const startDate = `01-${this.addCeroAtBegin(month)}-${year}`;
216
+ const endDate = `${DateHelper.getDaysInMonth(
217
+ month,
218
+ year
219
+ )}-${this.addCeroAtBegin(month)}-${year}`;
220
+ return { startDate, endDate };
221
+ }
178
222
  }
179
223
 
180
224
  // Client code using dependency inversion
@@ -216,6 +260,27 @@ class DateService {
216
260
  public getISODateStringFromString(date: string): string {
217
261
  return this.dateManipulator.getISODateStringFromString(date);
218
262
  }
263
+
264
+ public getCurrentYear(): number {
265
+ return this.dateManipulator.getCurrentYear();
266
+ }
267
+
268
+ public getStartAndEndDateOfMonth(month: number): {
269
+ startDate: string;
270
+ endDate: string;
271
+ } {
272
+ return this.dateManipulator.getStartAndEndDateOfMonth(month);
273
+ }
274
+
275
+ public getStartAndEndDateOfMonthWithYear(
276
+ month: number,
277
+ year: number
278
+ ): {
279
+ startDate: string;
280
+ endDate: string;
281
+ } {
282
+ return this.dateManipulator.getStartAndEndDateOfMonthWithYear(month, year);
283
+ }
219
284
  }
220
285
  const DisacompDateService = new DateService(new DateManipulator());
221
286
 
@@ -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":"03090d132ef006986522135d56b70b04304c49fb91a0f78c94e2b0ecd92e39ae","signature":"213ee2e4b19d70af1c66ec975e2c27fe3c7f8531d05a628270eb52f821786e00"}],"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
+ {"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":"8cde80f3134ae2a1dea2340be1dfea80a82c01ad2fdd8d53e758ce5b54ec4bc2","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"}