Skip to content

Commit a9d66a9

Browse files
author
Andrew Yoo
committed
Add is_dst parameter based on time's tm_isdst field instead of passing in None all the time
1 parent 556f519 commit a9d66a9

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

django_celery_beat/utils.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# -- a recursive loader import!
44
from django.conf import settings
55
from django.utils import timezone
6+
import time
67

78
is_aware = timezone.is_aware
89
# celery schedstate return None will make it not work
@@ -24,7 +25,15 @@ def make_aware(value):
2425
else:
2526
# naive datetimes are assumed to be in local timezone.
2627
if timezone.is_naive(value):
27-
value = timezone.make_aware(value, timezone.get_default_timezone())
28+
tm_isdst = time.localtime().tm_isdst
29+
30+
# tm_isdst may return -1 if it cannot be determined
31+
if tm_isdst == -1:
32+
is_dst = None
33+
else:
34+
is_dst = bool(tm_isdst)
35+
36+
value = timezone.make_aware(value, timezone.get_default_timezone(), is_dst=is_dst)
2837
return value
2938

3039

0 commit comments

Comments
 (0)