MCPcopy
hub / github.com/django/django / get_fixed_timezone

Function get_fixed_timezone

django/utils/timezone.py:33–40  ·  view source on GitHub ↗

Return a tzinfo instance with a fixed offset from UTC.

(offset)

Source from the content-addressed store, hash-verified

31
32
33def get_fixed_timezone(offset):
34 """Return a tzinfo instance with a fixed offset from UTC."""
35 if isinstance(offset, timedelta):
36 offset = offset.total_seconds() // 60
37 sign = "-" if offset < 0 else "+"
38 hhmm = "%02d%02d" % divmod(abs(offset), 60)
39 name = sign + hhmm
40 return timezone(timedelta(minutes=offset), name)
41
42
43# In order to avoid accessing settings at compile time,

Callers 11

parse_datetimeFunction · 0.90
test_parse_datetimeMethod · 0.90
test_timezonesMethod · 0.90
item_pubdateMethod · 0.90
test_timezonesMethod · 0.90
test_naturalday_tzMethod · 0.90

Calls

no outgoing calls

Tested by 9

test_parse_datetimeMethod · 0.72
test_timezonesMethod · 0.72
test_timezonesMethod · 0.72
test_naturalday_tzMethod · 0.72