disacomp-dateservice 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +11 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "disacomp-dateservice",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Disacomp Date Service",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -43,6 +43,7 @@ interface IDateManipulator {
43
43
  getPeriodFromDate(date: string): string;
44
44
  isValidDate(date: string): boolean;
45
45
  getSignDate(): string;
46
+ getISODateStringFromString(date: string): string;
46
47
  }
47
48
 
48
49
  // Helper class to handle leap years and days in months
@@ -168,6 +169,12 @@ class DateManipulator implements IDateManipulator {
168
169
 
169
170
  return `${day}-${month}-${year} ${hours}:${min}:${sec}`;
170
171
  }
172
+
173
+ public getISODateStringFromString(date: string): string {
174
+ const [day, month, year] = date.split("-").map(Number);
175
+
176
+ return `${year}-${this.addCeroAtBegin(month)}-${this.addCeroAtBegin(day)}`; // Formato ISO YYYY-MM-DD
177
+ }
171
178
  }
172
179
 
173
180
  // Client code using dependency inversion
@@ -205,6 +212,10 @@ class DateService {
205
212
  public getSignDate(): string {
206
213
  return this.dateManipulator.getSignDate();
207
214
  }
215
+
216
+ public getISODateStringFromString(date: string): string {
217
+ return this.dateManipulator.getISODateStringFromString(date);
218
+ }
208
219
  }
209
220
  const DisacompDateService = new DateService(new DateManipulator());
210
221