Skip to content

Commit ff72ec6

Browse files
committed
Improves adding time performance.
1 parent 3cd6caa commit ff72ec6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pendulum/pendulum.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,13 +1192,15 @@ def add(self, years=0, months=0, weeks=0, days=0,
11921192
if any([years, months, weeks, days]):
11931193
# If we specified any of years, months, weeks or days
11941194
# we will not apply the transition (if any)
1195-
dt = self._tz.convert(
1196-
dt.replace(tzinfo=None),
1197-
dst_rule=Timezone.POST_TRANSITION
1195+
return self.__class__(
1196+
dt.year, dt.month, dt.day,
1197+
dt.hour, dt.minute, dt.second, dt.microsecond,
1198+
tzinfo=self._tz,
1199+
fold=1
11981200
)
1199-
else:
1200-
# Else, we need to apply the transition properly (if any)
1201-
dt = self._tz.convert(dt)
1201+
1202+
# Else, we need to apply the transition properly (if any)
1203+
dt = self._tz.convert(dt)
12021204

12031205
return self.instance(dt)
12041206

0 commit comments

Comments
 (0)