Repository navigation
Fix DST-aware midnight release handling for PT/ET platforms - #1
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates release-time resolution so that “global midnight” platform strategies (PT/ET) convert local midnight on the episode’s air_date into the correct UTC instant, including DST-aware offsets.
Changes:
- Added a
strategyTimezonemapping and updatedresolveDateTimeto route select strategies through a local-time conversion. - Implemented
localMidnightToUtc+getTimezoneOffsetMinutesusingIntl.DateTimeFormat.formatToPartsto compute date-specific timezone offsets (DST-aware). - Added a regression test asserting PT-local midnight maps to the correct UTC time for a winter date.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/release.ts |
Adds timezone-aware conversion logic for PT/ET “global midnight” strategies using Intl offset computation. |
tests/release.test.ts |
Adds a DST-focused regression test for PT midnight → UTC conversion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+74
to
+77
| const utcMidday = Date.UTC(year, month - 1, day, 12, 0, 0); | ||
| const offsetMinutes = getTimezoneOffsetMinutes(utcMidday, timezone); | ||
| const utcMillis = Date.UTC(year, month - 1, day, 0, 0, 0) - offsetMinutes * 60 * 1000; | ||
|
|
| it("uses DST-aware PT midnight conversion", () => { | ||
| expect(resolveDateTime({ ...baseShow, network: "Netflix" }, { ...baseEpisode, air_date: "2026-01-15" })).toBe( | ||
| "2026-01-15T08:00:00Z", | ||
| ); |
Comment on lines
+81
to
+91
| function getTimezoneOffsetMinutes(timestamp: number, timezone: string): number { | ||
| const dtf = new Intl.DateTimeFormat("en-US", { | ||
| timeZone: timezone, | ||
| year: "numeric", | ||
| month: "2-digit", | ||
| day: "2-digit", | ||
| hour: "2-digit", | ||
| minute: "2-digit", | ||
| second: "2-digit", | ||
| hourCycle: "h23", | ||
| }); |
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.
Motivation
Description
strategyTimezonemapping and use it inresolveDateTimeto detect when a platform strategy requires a local-timezone conversion.localMidnightToUtcwhich computes the correct UTC timestamp for local midnight on the givenair_date.getTimezoneOffsetMinutesusingIntl.DateTimeFormat.formatToPartsto compute the date-specific offset (handles DST).uses DST-aware PT midnight conversion) and keep existing behavior forexactRelease, explicitreleaseTime, and non-midnight strategies; modified files:src/release.ts,tests/release.test.ts.Testing
pnpm test -- --run tests/release.test.ts tests/tmdb.test.ts.28tests passed (no failures).