Professor-Pine
Professor-Pine copied to clipboard
Adjust raid times when tz for server is different than location of players
It would be nice to have a setting within private-settings.json to be able to set the tz of the actual play location.
Finally spent the small amount of time to fix this. The fix may not be the most ideal and may work for fractional tz offsets. I didn't test it for values such as -2.5 in order to represent an offset of 2:30 minutes. It will however work just fine for full hour offsets.
You can see the diff here in my personal fork.
https://github.com/digumo/Professor-Pine/pull/1/commits/f6314328271cb111ce004565c64de1cdd3c65289
@Googer can you look over this and approve it
@digumo if you'd like to submit a pull request that would help us out.
Please don't attempt to reinvent timezone arithmetic. Dealing with a server in a different zone from your own is generally not as simple as adding/subtracting hours, as there are many regions of the world which, for example, don't use Daylight Saving Time or which change clocks on different dates than others might, so the relative offsets are often not consistent.
Fortunately, moment has a subproject, moment-timezone, which is designed for exactly this sort of thing. Rather than trying to calculate something like moment().subtract(2, 'hours'), you simply do the conversion with something like moment().tz('America/Denver'), where America/Denver is the tz identifier for the desired region.
The only caveat is that global timezone definitions change often at the whim of various national politics. If you or your server are in an area where such last-minute changes are commonplace, you'll want to make sure you're pulling/applying updated data fairly frequently, but package management can help with that.