mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 22:43:42 +00:00
Otherwise one gets: AttributeError: 'module' object has no attribute 'time' when trying to use the time module from inside zephyr.lib. (imported from commit 645368672a3eff68320278dd480edeed56721fcc)
10 lines
294 B
Python
10 lines
294 B
Python
import datetime
|
|
import calendar
|
|
from django.utils.timezone import utc
|
|
|
|
def timestamp_to_datetime(timestamp):
|
|
return datetime.datetime.utcfromtimestamp(float(timestamp)).replace(tzinfo=utc)
|
|
|
|
def datetime_to_timestamp(datetime_object):
|
|
return calendar.timegm(datetime_object.timetuple())
|