-
Notifications
You must be signed in to change notification settings - Fork 7
Description
First of all, thanks for making Strautomator! It's been working so well and reliably for me!
Recently, when trying to change the weather info provider, I used the Weather comparison page and found some weird behavior - it incorrectly thought it was night when it was 3PM in my time zone and it was sunny outside:
I'm completely new to the codebase, but after some digging and with help from AI tools, I suspect there's something wrong with the time zone offset calculation.
AI claims that (sorry but I know nothing about JS and can't fact check it):
The Bug: Inverted Timezone Sign
The issue is a mismatch between how the browser calculates the timezone offset and how the server-side library (dayjs) expects it.
- Frontend (pages/weather/select.vue): You are using
new Date().getTimezoneOffset(). In JavaScript, this returns the difference in minutes between UTC and Local Time.
- Crucially: It returns a positive value for timezones behind UTC (e.g., New York is UTC-5, but returns 300) and a negative value for timezones ahead of UTC (e.g., Sydney is UTC+11, but returns -660).
- Backend (src/routes/api/weather.ts): The API route receives this value and passes it to
dayjs().utcOffset():
- dayjs (following ISO 8601) expects the opposite: negative for West (UTC-5 should be -300) and positive for East (UTC+11 should be 660).
As a sanity check, I manually flipped the offset from -660 to 660 and resent the API request, and the response looked much more reasonable (at least no 🌙 s).
Apologies if AI hallucinated and misled me. Thanks again for maintaining Stautomator :)