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

Method instance

src/pendulum/datetime.py:125–145  ·  view source on GitHub ↗
(
        cls,
        dt: datetime.datetime,
        tz: str | Timezone | FixedTimezone | datetime.tzinfo | None = UTC,
    )

Source from the content-addressed store, hash-verified

123
124 @classmethod
125 def instance(
126 cls,
127 dt: datetime.datetime,
128 tz: str | Timezone | FixedTimezone | datetime.tzinfo | None = UTC,
129 ) -> Self:
130 tz = dt.tzinfo or tz
131
132 if tz is not None:
133 tz = pendulum._safe_timezone(tz, dt=dt)
134
135 return cls.create(
136 dt.year,
137 dt.month,
138 dt.day,
139 dt.hour,
140 dt.minute,
141 dt.second,
142 dt.microsecond,
143 tz=tz,
144 fold=dt.fold,
145 )
146
147 @overload
148 @classmethod

Callers 11

closestMethod · 0.95
farthestMethod · 0.95
is_same_dayMethod · 0.95
is_anniversaryMethod · 0.95
__sub__Method · 0.95
__rsub__Method · 0.95
strptimeMethod · 0.45
fromtimestampMethod · 0.45
utcfromtimestampMethod · 0.45
fromordinalMethod · 0.45
combineMethod · 0.45

Calls 1

createMethod · 0.80

Tested by

no test coverage detected