MCPcopy Index your code
hub / github.com/python-pendulum/pendulum / _normalize

Function _normalize

src/pendulum/parsing/__init__.py:81–107  ·  view source on GitHub ↗

Normalizes the parsed element. :param parsed: The parsed elements.

(
    parsed: datetime | date | time | _Interval | Duration, **options: Any
)

Source from the content-addressed store, hash-verified

79
80
81def _normalize(
82 parsed: datetime | date | time | _Interval | Duration, **options: Any
83) -> datetime | date | time | _Interval | Duration:
84 """
85 Normalizes the parsed element.
86
87 :param parsed: The parsed elements.
88 """
89 if options.get("exact"):
90 return parsed
91
92 if isinstance(parsed, time):
93 now = cast("Optional[datetime]", options["now"]) or datetime.now()
94
95 return datetime(
96 now.year,
97 now.month,
98 now.day,
99 parsed.hour,
100 parsed.minute,
101 parsed.second,
102 parsed.microsecond,
103 )
104 elif isinstance(parsed, date) and not isinstance(parsed, datetime):
105 return datetime(parsed.year, parsed.month, parsed.day)
106
107 return parsed
108
109
110def _parse(text: str, **options: Any) -> datetime | date | time | _Interval | Duration:

Callers 1

parseFunction · 0.85

Calls 3

datetimeFunction · 0.85
getMethod · 0.80
nowMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…