doesitrain.today
doesitrain.today copied to clipboard
Enhance timezones support
A few months ago, I noticed that the time at which the bot was sending me a reminder was a bit off. A couple of weeks ago, I had that same feeling again - so I gave a second look at the history:

When we went from summertime to wintertime in Europe/Amsterdam, the bot went back one hour. 😅
This PR fixes it by changing the way the hour to send it saved:
- Currently, the
set_time
determines the time to save in the DB by computing the difference between the current time locally and at the specified location. - With this commit,
set_time
saves both the time to send, as well as the user's timezone. When the hourly job is triggered, if there's a timezone saved in the DB, it uses it to determine if it's the time to send locally. Otherwise, it uses the machine's local time (to keep compatibility with older saved times).
I'm not too experienced with Ruby, so I'd glad to take any feedback!