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

Method __init__

src/pendulum/interval.py:119–185  ·  view source on GitHub ↗
(self, start: _T, end: _T, absolute: bool = False)

Source from the content-addressed store, hash-verified

117 return super().__new__(cls, seconds=delta.total_seconds())
118
119 def __init__(self, start: _T, end: _T, absolute: bool = False) -> None:
120 super().__init__()
121
122 _start: _T
123 if not isinstance(start, pendulum.Date):
124 if isinstance(start, datetime):
125 start = cast("_T", pendulum.instance(start))
126 else:
127 start = cast("_T", pendulum.date(start.year, start.month, start.day))
128
129 _start = start
130 else:
131 if isinstance(start, pendulum.DateTime):
132 _start = cast(
133 "_T",
134 datetime(
135 start.year,
136 start.month,
137 start.day,
138 start.hour,
139 start.minute,
140 start.second,
141 start.microsecond,
142 tzinfo=start.tzinfo,
143 ),
144 )
145 else:
146 _start = cast("_T", date(start.year, start.month, start.day))
147
148 _end: _T
149 if not isinstance(end, pendulum.Date):
150 if isinstance(end, datetime):
151 end = cast("_T", pendulum.instance(end))
152 else:
153 end = cast("_T", pendulum.date(end.year, end.month, end.day))
154
155 _end = end
156 else:
157 if isinstance(end, pendulum.DateTime):
158 _end = cast(
159 "_T",
160 datetime(
161 end.year,
162 end.month,
163 end.day,
164 end.hour,
165 end.minute,
166 end.second,
167 end.microsecond,
168 tzinfo=end.tzinfo,
169 ),
170 )
171 else:
172 _end = cast("_T", date(end.year, end.month, end.day))
173
174 self._invert = False
175 if start > end:
176 self._invert = True

Callers

nothing calls this directly

Calls 5

precise_diffFunction · 0.90
datetimeFunction · 0.85
dateFunction · 0.85
dateMethod · 0.80
instanceMethod · 0.45

Tested by

no test coverage detected