MCPcopy
hub / github.com/celery/celery / _is_ambiguous

Function _is_ambiguous

celery/utils/time.py:338–348  ·  view source on GitHub ↗

Helper function to determine if a timezone is ambiguous using python's dateutil module. Returns False if the timezone cannot detect ambiguity, or if there is no ambiguity, otherwise True. In order to detect ambiguous datetimes, the timezone must be built using ZoneInfo, or have an is_ambig

(dt: datetime, tz: tzinfo)

Source from the content-addressed store, hash-verified

336
337
338def _is_ambiguous(dt: datetime, tz: tzinfo) -> bool:
339 """Helper function to determine if a timezone is ambiguous using python's dateutil module.
340
341 Returns False if the timezone cannot detect ambiguity, or if there is no ambiguity, otherwise True.
342
343 In order to detect ambiguous datetimes, the timezone must be built using ZoneInfo, or have an is_ambiguous
344 method. Previously, pytz timezones would throw an AmbiguousTimeError if the localized dt was ambiguous,
345 but now we need to specifically check for ambiguity with dateutil, as pytz is deprecated.
346 """
347
348 return _can_detect_ambiguous(tz) and dateutil_tz.datetime_ambiguous(dt)
349
350
351def make_aware(dt: datetime, tz: tzinfo) -> datetime:

Callers 1

make_awareFunction · 0.85

Calls 1

_can_detect_ambiguousFunction · 0.85

Tested by

no test coverage detected