Skip to content

chore: fixed code logic (timezones 🤷) - #187

Open
fearphage wants to merge 2 commits into
backstage:mainfrom
fearphage:cron/fix-test
Open

chore: fixed code logic (timezones 🤷)#187
fearphage wants to merge 2 commits into
backstage:mainfrom
fearphage:cron/fix-test

Conversation

@fearphage

@fearphage fearphage commented Aug 7, 2026

Copy link
Copy Markdown

This test fails consistently locally. There seems to be a logic issue with respect to time zones.

Details

The test expects to run on midnight Tuesday UTC (2022-06-28) using a fake timer. However it was actually generating a date that was relative to the local time. So for me, midnight UTC is 7pm CDT on the previous day (06-27 which is a Monday) so the test would fail. I patched this by always adjusting the time based on the timezone offset.

Verification

From a very basic set of local testing, it seems to pass consistently (where the main branch fails):

➜  backstage-actions git:(cron/fix-test) for x in America/Los_Angeles America/New_York Etc/GMT Africa/Nairobi Asia/Tokyo Pacific/Kiritimati; do if env TZ="$x" yarn test cron/mergeRenovatePRs.test.ts &> /dev/null; then outcome='passed'; else outcome='FAILED'; fi; printf '%-20s -> %s\n' "$x" "$outcome"; done
America/Los_Angeles  -> passed
America/New_York     -> passed
Etc/GMT              -> passed
Africa/Nairobi       -> passed
Asia/Tokyo           -> passed
Pacific/Kiritimati   -> passed
➜  backstage-actions git:(cron/fix-test) gcm
Switched to branch 'main'
Your branch is up to date with 'origin/main'.
➜  backstage-actions git:(main) for x in America/Los_Angeles America/New_York Etc/GMT Africa/Nairobi Asia/Tokyo Pacific/Kiritimati; do if env TZ="$x" yarn test cron/mergeRenovatePRs.test.ts &> /dev/null; then outcome='passed'; else outcome='FAILED'; fi; printf '%-20s -> %s\n' "$x" "$outcome"; done
America/Los_Angeles  -> FAILED
America/New_York     -> FAILED
Etc/GMT              -> passed
Africa/Nairobi       -> passed
Asia/Tokyo           -> passed
Pacific/Kiritimati   -> passed

EDIT: I originally thought the test was bad, but the code was actually flawed. So I just fixed that instead.

Signed-off-by: Phred <fearphage@gmail.com>
Signed-off-by: Phred <fearphage@gmail.com>
@fearphage fearphage changed the title chore: fixed broken test (timezones 🤷) chore: fixed code logic (timezones 🤷) Aug 11, 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.

1 participant