@tmlmobilidade/generate-offer-files 20250626.1514.36 → 20250626.1759.25

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/main.js +2 -17
  2. package/package.json +1 -1
package/dist/main.js CHANGED
@@ -3,7 +3,7 @@ import LOGGER from '@helperkits/logger';
3
3
  import TIMETRACKER from '@helperkits/timer';
4
4
  import { JsonWriter } from '@helperkits/writer';
5
5
  import { validateOperationalDate } from '@tmlmobilidade/types';
6
- import { Dates } from '@tmlmobilidade/utils';
6
+ import { Dates, getOperationalDatesFromRange } from '@tmlmobilidade/utils';
7
7
  import { parse as csvParser } from 'csv-parse';
8
8
  import extract from 'extract-zip';
9
9
  import fs from 'fs';
@@ -101,7 +101,7 @@ export async function generateOfferOutput(filePath, startDate, endDate, outputDi
101
101
  // If we're here, it means the service_id is valid between the given dates.
102
102
  // For the configured weekly schedule, create the individual operational dates
103
103
  // for each day of the week that is active.
104
- const allOperationalDatesInRange = getIndividualDatesFromRange(serviceIdStartDate, serviceIdEndDate);
104
+ const allOperationalDatesInRange = getOperationalDatesFromRange(serviceIdStartDate, serviceIdEndDate);
105
105
  const validOperationalDates = [];
106
106
  for (const currentDate of allOperationalDatesInRange) {
107
107
  const dayOfWeek = Dates.fromOperationalDate(currentDate, 'Europe/Lisbon').toFormat('c');
@@ -621,18 +621,3 @@ const convertMetersOrKilometersToMeters = (value, ballpark) => {
621
621
  }
622
622
  //
623
623
  };
624
- /* * */
625
- export function getIndividualDatesFromRange(start, end) {
626
- if (end < start)
627
- throw new Error(`End date "${end}" must be after start date "${start}"`);
628
- // Parse the start and end dates to ensure they are in the correct format
629
- const startDate = Dates.fromOperationalDate(start, 'Europe/Lisbon');
630
- const endDate = Dates.fromOperationalDate(end, 'Europe/Lisbon');
631
- const dates = [];
632
- let current = startDate;
633
- while (current.operational_date <= endDate.operational_date) {
634
- dates.push(current.operational_date);
635
- current = current.plus({ days: 1 });
636
- }
637
- return dates;
638
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tmlmobilidade/generate-offer-files",
3
- "version": "20250626.1514.36",
3
+ "version": "20250626.1759.25",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"