File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 1616
1717from . import managers
1818from .picklefield import PickledObjectField
19- from .utils import now
19+ from .utils import fromtimestamp , now
2020from .compat import python_2_unicode_compatible
2121
2222TASK_STATE_CHOICES = zip (states .ALL_STATES , states .ALL_STATES )
@@ -360,11 +360,11 @@ class Meta:
360360
361361 def save (self , * args , ** kwargs ):
362362 if self .eta is not None :
363- self .eta = datetime . utcfromtimestamp (float ('%d.%s' % (
363+ self .eta = fromtimestamp (float ('%d.%s' % (
364364 mktime (self .eta .timetuple ()), self .eta .microsecond ,
365365 )))
366366 if self .expires is not None :
367- self .expires = datetime . utcfromtimestamp (float ('%d.%s' % (
367+ self .expires = fromtimestamp (float ('%d.%s' % (
368368 mktime (self .expires .timetuple ()), self .expires .microsecond ,
369369 )))
370370 super (TaskState , self ).save (* args , ** kwargs )
Original file line number Diff line number Diff line change 1313from celery .utils .timeutils import maybe_iso8601
1414
1515from .models import WorkerState , TaskState
16- from .utils import maybe_make_aware
16+ from .utils import fromtimestamp , maybe_make_aware
1717
1818WORKER_UPDATE_FREQ = 60 # limit worker timestamp write freq.
1919SUCCESS_STATES = frozenset ([states .SUCCESS ])
3333
3434def aware_tstamp (secs ):
3535 """Event timestamps uses the local timezone."""
36- return maybe_make_aware (datetime . utcfromtimestamp (secs ))
36+ return maybe_make_aware (fromtimestamp (secs ))
3737
3838
3939class Camera (Polaroid ):
Original file line number Diff line number Diff line change @@ -93,3 +93,10 @@ def is_database_scheduler(scheduler):
9393 from kombu .utils import symbol_by_name
9494 from .schedulers import DatabaseScheduler
9595 return issubclass (symbol_by_name (scheduler ), DatabaseScheduler )
96+
97+
98+ def fromtimestamp (value ):
99+ if getattr (settings , 'CELERY_ENABLE_UTC' , False ):
100+ return datetime .utcfromtimestamp (value )
101+ else :
102+ return datetime .fromtimestamp (value )
You can’t perform that action at this time.
0 commit comments