Return a tzinfo instance with a fixed offset from UTC.
(offset)
| 31 | |
| 32 | |
| 33 | def 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, |
no outgoing calls