Really fix the timezones

Two main changes:

- uses `astimezone` instead of `replace` because `replace` doesn’t
  handle daylight savings time correctly [1]
- create the notifications one second before midnight in BST, because
  midnight is actually counted as being start of the _next_ day, month,
  etc

1. http://www.saltycrane.com/blog/2009/05/converting-time-zones-datetime-objects-python/#add-timezone-localize
This commit is contained in:
Chris Hill-Scott
2016-10-04 13:00:37 +01:00
parent 76d5f14952
commit d352c0eed9
2 changed files with 11 additions and 12 deletions

View File

@@ -359,6 +359,6 @@ def get_april_fools(year):
def get_bst_month(datetime):
return pytz.utc.localize(datetime).replace(
tzinfo=pytz.timezone("Europe/London")
return pytz.utc.localize(datetime).astimezone(
pytz.timezone("Europe/London")
).strftime('%B')