MCPcopy
hub / github.com/celery/celery / make_aware

Function make_aware

celery/utils/time.py:351–357  ·  view source on GitHub ↗

Set timezone for a :class:`~datetime.datetime` object.

(dt: datetime, tz: tzinfo)

Source from the content-addressed store, hash-verified

349
350
351def make_aware(dt: datetime, tz: tzinfo) -> datetime:
352 """Set timezone for a :class:`~datetime.datetime` object."""
353
354 dt = dt.replace(tzinfo=tz)
355 if _is_ambiguous(dt, tz):
356 dt = min(dt.replace(fold=0), dt.replace(fold=1))
357 return dt
358
359
360def localize(dt: datetime, tz: tzinfo) -> datetime:

Callers 11

test_to_localMethod · 0.90
test_standard_tzMethod · 0.90
test_tz_when_zoneinfoMethod · 0.90
test_standard_tzMethod · 0.90
test_when_zoneinfoMethod · 0.90
to_localMethod · 0.85
to_local_fallbackMethod · 0.85
localizeFunction · 0.85
to_utcFunction · 0.85

Calls 2

_is_ambiguousFunction · 0.85
replaceMethod · 0.45

Tested by 7

test_to_localMethod · 0.72
test_standard_tzMethod · 0.72
test_tz_when_zoneinfoMethod · 0.72
test_standard_tzMethod · 0.72
test_when_zoneinfoMethod · 0.72