Permalink
Browse files

fix dst issue

  • Loading branch information...
1 parent 3c618d9 commit 7188e72dfc9aa19003ba5fde2c324cf7981aa714 @fangeugene fangeugene committed Mar 8, 2015
Showing with 4 additions and 1 deletion.
  1. +4 −1 models/event.py
View
@@ -128,7 +128,10 @@ def withinDays(self, negative_days_before, days_after):
now = datetime.datetime.now()
if self.timezone_id is not None:
tz = pytz.timezone(self.timezone_id)
- now = now - tz.utcoffset(now)
+ try:
+ now = now - tz.utcoffset(now)
+ except pytz.NonExistentTimeError: # may happen during DST
+ now = now - tz.utcoffset(now + datetime.timedelta(hours=1)) # add offset to get out of non-existant time
today = now.today()
after_start = self.start_date.date() + datetime.timedelta(days=negative_days_before) <= today.date()
before_end = self.end_date.date() + datetime.timedelta(days=days_after) >= today.date()

0 comments on commit 7188e72

Please sign in to comment.