Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/rest_framework_simplejwt/utils.py: 85%
18 statements
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2023-07-17 14:22 -0600
1from calendar import timegm
2from datetime import datetime
4from django.conf import settings
5from django.utils.functional import lazy
6from django.utils.timezone import is_naive, make_aware, utc
9def make_utc(dt):
10 if settings.USE_TZ and is_naive(dt): 10 ↛ 13line 10 didn't jump to line 13, because the condition on line 10 was never false
11 return make_aware(dt, timezone=utc)
13 return dt
16def aware_utcnow():
17 return make_utc(datetime.utcnow())
20def datetime_to_epoch(dt):
21 return timegm(dt.utctimetuple())
24def datetime_from_epoch(ts):
25 return make_utc(datetime.utcfromtimestamp(ts))
28def format_lazy(s, *args, **kwargs):
29 return s.format(*args, **kwargs)
32format_lazy = lazy(format_lazy, str)