Skip to content

Commit

Permalink
Default to UTC if not local timezone can be found
Browse files Browse the repository at this point in the history
Fixes #715
  • Loading branch information
sdispater committed Aug 15, 2023
1 parent 9590c65 commit 8792507
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pendulum/tz/local_timezone.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import os
import re
import sys
import warnings

from contextlib import contextmanager
from typing import Iterator
from typing import cast

from pendulum.tz.exceptions import InvalidTimezone
from pendulum.tz.timezone import UTC
from pendulum.tz.timezone import FixedTimezone
from pendulum.tz.timezone import Timezone

Expand Down Expand Up @@ -239,7 +241,11 @@ def _get_unix_timezone(_root: str = "/") -> Timezone:
with open(tzpath, "rb") as f:
return Timezone.from_file(f)

raise RuntimeError("Unable to find any timezone configuration")
warnings.warn(
"Unable not find any timezone configuration, defaulting to UTC.", stacklevel=1
)

return UTC


def _tz_from_env(tzenv: str) -> Timezone:
Expand Down

0 comments on commit 8792507

Please sign in to comment.