Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/pendulum/tz/__init__.py: 72%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3from functools import cache
4from zoneinfo import available_timezones
6from pendulum.tz.local_timezone import get_local_timezone
7from pendulum.tz.local_timezone import set_local_timezone
8from pendulum.tz.local_timezone import test_local_timezone
9from pendulum.tz.timezone import UTC
10from pendulum.tz.timezone import FixedTimezone
11from pendulum.tz.timezone import Timezone
14PRE_TRANSITION = "pre"
15POST_TRANSITION = "post"
16TRANSITION_ERROR = "error"
18_tz_cache: dict[int, FixedTimezone] = {}
21@cache
22def timezones() -> set[str]:
23 return available_timezones()
26def fixed_timezone(offset: int) -> FixedTimezone:
27 """
28 Return a Timezone instance given its offset in seconds.
29 """
30 if offset in _tz_cache:
31 return _tz_cache[offset]
33 tz = FixedTimezone(offset)
34 _tz_cache[offset] = tz
36 return tz
39def local_timezone() -> Timezone | FixedTimezone:
40 """
41 Return the local timezone.
42 """
43 return get_local_timezone()
46__all__ = [
47 "UTC",
48 "FixedTimezone",
49 "Timezone",
50 "fixed_timezone",
51 "get_local_timezone",
52 "local_timezone",
53 "set_local_timezone",
54 "test_local_timezone",
55 "timezones",
56]