@tmlmobilidade/go-utils-dates 20260905.1406.50 → 20260905.2252.20

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/dist/dates.js +7 -2
  2. package/package.json +1 -1
package/dist/dates.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable @typescript-eslint/naming-convention */
2
- import { CALENDAR_DATE_FORMAT, OPERATIONAL_DATE_FORMAT } from '@tmlmobilidade/go-types-shared';
2
+ import { CALENDAR_DATE_FORMAT, OPERATIONAL_DATE_FORMAT, OperationalDateIntSchema } from '@tmlmobilidade/go-types-shared';
3
3
  import { DateTime } from 'luxon';
4
4
  import { DateFormatConfigMap } from './date-format.js';
5
5
  /* * */
@@ -84,8 +84,13 @@ export class Dates {
84
84
  * @returns A new Dates object created from the operational date.
85
85
  */
86
86
  static fromOperationalDateInt(date, timezone) {
87
+ // Validate the date
88
+ const validatedDate = OperationalDateIntSchema.safeParse(date);
89
+ if (!validatedDate.success)
90
+ throw new Error(`Received an invalid operational date: ${date} - ${validatedDate.error.message}`);
91
+ // Create the date time object
87
92
  const dateTime = DateTime
88
- .fromFormat(String(date), OPERATIONAL_DATE_FORMAT)
93
+ .fromFormat(String(validatedDate.data), OPERATIONAL_DATE_FORMAT)
89
94
  .setZone(timezone, { keepLocalTime: true })
90
95
  .set({ hour: 4, millisecond: 0, minute: 0, second: 0 }); // Start of the operational date
91
96
  return new Dates({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/go-utils-dates",
3
- "version": "20260905.1406.50",
3
+ "version": "20260905.2252.20",
4
4
  "author": {
5
5
  "email": "iso@tmlmobilidade.pt",
6
6
  "name": "TML-ISO"