gtfs-to-html 2.11.1 → 2.11.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.
package/dist/index.js CHANGED
@@ -62,6 +62,9 @@ function toGTFSTime(time) {
62
62
  return time.format("HH:mm:ss");
63
63
  }
64
64
  function calendarToCalendarCode(c) {
65
+ if (Object.values(c).every((value) => value === null)) {
66
+ return "";
67
+ }
65
68
  return `${c.monday}${c.tuesday}${c.wednesday}${c.thursday}${c.friday}${c.saturday}${c.sunday}`;
66
69
  }
67
70
  function calendarCodeToCalendar(code) {
@@ -494,7 +497,7 @@ function formatTripNameForCSV(trip, timetable) {
494
497
  // package.json
495
498
  var package_default = {
496
499
  name: "gtfs-to-html",
497
- version: "2.11.1",
500
+ version: "2.11.2",
498
501
  private: false,
499
502
  description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
500
503
  keywords: [
@@ -886,7 +889,15 @@ var createTimetable = ({
886
889
  ...calendars?.map((calendar) => calendar.service_id) ?? [],
887
890
  ...calendarDates?.map((calendarDate) => calendarDate.service_id) ?? []
888
891
  ]);
889
- const days2 = {};
892
+ const days2 = {
893
+ monday: null,
894
+ tuesday: null,
895
+ wednesday: null,
896
+ thursday: null,
897
+ friday: null,
898
+ saturday: null,
899
+ sunday: null
900
+ };
890
901
  let startDate = null;
891
902
  let endDate = null;
892
903
  if (calendars && calendars.length > 0) {
@@ -905,7 +916,8 @@ var createTimetable = ({
905
916
  const timetableId = formatTimetableId({
906
917
  routeIds: [route.route_id],
907
918
  directionId,
908
- days: days2
919
+ days: days2,
920
+ dates: calendarDates?.map((calendarDate) => calendarDate.date)
909
921
  });
910
922
  return {
911
923
  timetable_id: timetableId,
@@ -978,6 +990,9 @@ var convertRoutesToTimetablePages = (config) => {
978
990
  }
979
991
  }
980
992
  }
993
+ if (timetables.length === 0) {
994
+ continue;
995
+ }
981
996
  if (config.groupTimetablesIntoPages === true) {
982
997
  timetablePages.push(
983
998
  createTimetablePage({
@@ -2068,9 +2083,15 @@ function formatFrequency(frequency, config) {
2068
2083
  function formatTimetableId({
2069
2084
  routeIds,
2070
2085
  directionId,
2071
- days: days2
2086
+ days: days2,
2087
+ dates
2072
2088
  }) {
2073
- let timetableId = `${routeIds.join("_")}|${calendarToCalendarCode(days2)}`;
2089
+ let timetableId = routeIds.join("_");
2090
+ if (calendarToCalendarCode(days2)) {
2091
+ timetableId += `|${calendarToCalendarCode(days2)}`;
2092
+ } else if (dates && dates.length > 0) {
2093
+ timetableId += `|${dates.join("_")}`;
2094
+ }
2074
2095
  if (!isNullOrEmpty(directionId)) {
2075
2096
  timetableId += `|${directionId}`;
2076
2097
  }
@@ -2367,7 +2388,12 @@ function generateTimetablePageFileName(timetablePage, config) {
2367
2388
  return sanitize(`${formatRouteNameForFilename(route).toLowerCase()}.html`);
2368
2389
  }
2369
2390
  const timetable = timetablePage.timetables[0];
2370
- let filename = timetable.timetable_id ?? "";
2391
+ if (timetable.timetable_id) {
2392
+ return sanitize(
2393
+ `${timetable.timetable_id.replace(/\|/g, "_").toLowerCase()}.html`
2394
+ );
2395
+ }
2396
+ let filename = "";
2371
2397
  for (const route of timetable.routes) {
2372
2398
  filename += `_${formatRouteNameForFilename(route)}`;
2373
2399
  }