doesitrain.today icon indicating copy to clipboard operation
doesitrain.today copied to clipboard

Enhance timezones support

Open egourlao opened this issue 6 years ago • 0 comments

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:

screenshot 2018-11-13 at 11 22 28

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!

egourlao avatar Nov 13 '18 10:11 egourlao