Skip to content

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

Merged
freben merged 2 commits into
backstage:mainfrom
fearphage:cron/fix-test
Sep 4, 2026
Merged

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

Conversation

@fearphage

@fearphage fearphage commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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
@fearphage fearphage closed this Aug 31, 2026
@fearphage fearphage reopened this Aug 31, 2026
@freben
freben merged commit 1bb93e3 into backstage:main Sep 4, 2026
4 of 5 checks passed
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