fix: update dates#5
Closed
gtokman wants to merge 1 commit into
Closed
Conversation
Contributor
There was a problem hiding this comment.
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
ArrivalwitharrivalTimestamp,arrivalDate, and optional departure timestamp/date fields. - Populate the new fields for direct-feed subway and bus arrivals.
- Add
hydrateArrivalsand 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 on lines
+154
to
+156
| arrivalTimestamp: number; | ||
| arrivalTime: string; | ||
| arrivalDate: Date; |
Comment on lines
153
to
+156
| headsign?: string; | ||
| arrivalTimestamp: number; | ||
| arrivalTime: string; | ||
| arrivalDate: Date; |
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), | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.