HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //home/arjun/projects/aigenerator/venv/lib/python3.12/site-packages/timezone_field/backends/pytz.py
import pytz

from .base import TimeZoneBackend, TimeZoneNotFoundError


class PYTZBackend(TimeZoneBackend):
    utc_tzobj = pytz.utc
    all_tzstrs = pytz.all_timezones
    base_tzstrs = pytz.common_timezones

    def is_tzobj(self, value):
        return value is pytz.UTC or isinstance(value, pytz.tzinfo.BaseTzInfo)

    def to_tzobj(self, tzstr):
        try:
            return pytz.timezone(tzstr)
        except pytz.UnknownTimeZoneError as err:
            raise TimeZoneNotFoundError from err