Skip to content

fix: update dates#5

Closed
gtokman wants to merge 1 commit into
mainfrom
gary/make-dates-better
Closed

fix: update dates#5
gtokman wants to merge 1 commit into
mainfrom
gary/make-dates-better

Conversation

@gtokman
Copy link
Copy Markdown
Contributor

@gtokman gtokman commented May 27, 2026

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Arrival model returned by the SDK to include explicit timestamp and Date representations for arrival/departure times, and adds hydration logic so hosted API JSON responses produce real Date instances.

Changes:

  • Extend Arrival with arrivalTimestamp, arrivalDate, and optional departure timestamp/date fields.
  • Populate the new fields for direct-feed subway and bus arrivals.
  • Add hydrateArrivals and apply it to hosted subway/bus arrivals; expand tests to validate hydration and new fields.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/types.ts Extends the public Arrival type with timestamp and Date fields.
index.ts Populates new arrival/departure fields and hydrates hosted JSON responses into Date objects.
index.test.ts Adds assertions and a new test covering hosted hydration of date/timestamp fields.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/types.ts
Comment on lines +154 to +156
arrivalTimestamp: number;
arrivalTime: string;
arrivalDate: Date;
Comment thread src/types.ts
Comment on lines 153 to +156
headsign?: string;
arrivalTimestamp: number;
arrivalTime: string;
arrivalDate: Date;
Comment thread index.ts
Comment on lines +200 to +207
function hydrateArrivals(arrivals: Arrival[]) {
return arrivals.map((arrival) => ({
...arrival,
arrivalTimestamp: arrival.arrivalTimestamp ?? dateToUnixSecondsRequired(arrival.arrivalDate ?? arrival.arrivalTime),
arrivalDate: hydrateRequiredDate(arrival.arrivalDate ?? arrival.arrivalTime),
departureTimestamp: arrival.departureTimestamp ?? dateToUnixSeconds(arrival.departureDate ?? arrival.departureTime),
departureDate: hydrateDate(arrival.departureDate ?? arrival.departureTime),
}));
@gtokman gtokman closed this May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants