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/README.md CHANGED
@@ -83,6 +83,7 @@ Many transit agencies use `gtfs-to-html` to generate the schedule pages used on
83
83
  | [MVgo](https://mvgo.org) | Mountain View, California |
84
84
  | [Petaluma Transit](https://transit.cityofpetaluma.net) | Petaluma, California |
85
85
  | [rabbittransit](https://www.rabbittransit.org) | York and Adams County, Pennsylvania |
86
+ | [River Valley Transit](https://rivervalleytransit.com) | Middletown, Connecticut |
86
87
  | [Rogue Valley Transportation District](https://rvtd.org) | Medford, Oregon |
87
88
  | [RTC Washoe](https://www.rtcwashoe.com) | Reno, Nevada |
88
89
  | [Santa Barbara Metropolitan Transit District](https://sbmtd.gov) | Santa Barbara, California |
package/dist/app/index.js CHANGED
@@ -40,6 +40,9 @@ function toGTFSTime(time) {
40
40
  return time.format("HH:mm:ss");
41
41
  }
42
42
  function calendarToCalendarCode(c) {
43
+ if (Object.values(c).every((value) => value === null)) {
44
+ return "";
45
+ }
43
46
  return `${c.monday}${c.tuesday}${c.wednesday}${c.thursday}${c.friday}${c.saturday}${c.sunday}`;
44
47
  }
45
48
  function calendarCodeToCalendar(code) {
@@ -287,7 +290,12 @@ function generateTimetablePageFileName(timetablePage, config2) {
287
290
  return sanitize(`${formatRouteNameForFilename(route).toLowerCase()}.html`);
288
291
  }
289
292
  const timetable = timetablePage.timetables[0];
290
- let filename = timetable.timetable_id ?? "";
293
+ if (timetable.timetable_id) {
294
+ return sanitize(
295
+ `${timetable.timetable_id.replace(/\|/g, "_").toLowerCase()}.html`
296
+ );
297
+ }
298
+ let filename = "";
291
299
  for (const route of timetable.routes) {
292
300
  filename += `_${formatRouteNameForFilename(route)}`;
293
301
  }
@@ -422,7 +430,7 @@ function getAgencyGeoJSON(config2) {
422
430
  // package.json
423
431
  var package_default = {
424
432
  name: "gtfs-to-html",
425
- version: "2.11.1",
433
+ version: "2.11.2",
426
434
  private: false,
427
435
  description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
428
436
  keywords: [
@@ -814,7 +822,15 @@ var createTimetable = ({
814
822
  ...calendars?.map((calendar) => calendar.service_id) ?? [],
815
823
  ...calendarDates?.map((calendarDate) => calendarDate.service_id) ?? []
816
824
  ]);
817
- const days2 = {};
825
+ const days2 = {
826
+ monday: null,
827
+ tuesday: null,
828
+ wednesday: null,
829
+ thursday: null,
830
+ friday: null,
831
+ saturday: null,
832
+ sunday: null
833
+ };
818
834
  let startDate = null;
819
835
  let endDate = null;
820
836
  if (calendars && calendars.length > 0) {
@@ -833,7 +849,8 @@ var createTimetable = ({
833
849
  const timetableId = formatTimetableId({
834
850
  routeIds: [route.route_id],
835
851
  directionId,
836
- days: days2
852
+ days: days2,
853
+ dates: calendarDates?.map((calendarDate) => calendarDate.date)
837
854
  });
838
855
  return {
839
856
  timetable_id: timetableId,
@@ -906,6 +923,9 @@ var convertRoutesToTimetablePages = (config2) => {
906
923
  }
907
924
  }
908
925
  }
926
+ if (timetables.length === 0) {
927
+ continue;
928
+ }
909
929
  if (config2.groupTimetablesIntoPages === true) {
910
930
  timetablePages.push(
911
931
  createTimetablePage({
@@ -1942,9 +1962,15 @@ function formatFrequency(frequency, config2) {
1942
1962
  function formatTimetableId({
1943
1963
  routeIds,
1944
1964
  directionId,
1945
- days: days2
1965
+ days: days2,
1966
+ dates
1946
1967
  }) {
1947
- let timetableId = `${routeIds.join("_")}|${calendarToCalendarCode(days2)}`;
1968
+ let timetableId = routeIds.join("_");
1969
+ if (calendarToCalendarCode(days2)) {
1970
+ timetableId += `|${calendarToCalendarCode(days2)}`;
1971
+ } else if (dates && dates.length > 0) {
1972
+ timetableId += `|${dates.join("_")}`;
1973
+ }
1948
1974
  if (!isNullOrEmpty(directionId)) {
1949
1975
  timetableId += `|${directionId}`;
1950
1976
  }