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

Method add

src/pendulum/date.py:187–206  ·  view source on GitHub ↗

Add duration to the instance. :param years: The number of years :param months: The number of months :param weeks: The number of weeks :param days: The number of days

(
        self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0
    )

Source from the content-addressed store, hash-verified

185 # ADDITIONS AND SUBTRACTIONS
186
187 def add(
188 self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0
189 ) -> Self:
190 """
191 Add duration to the instance.
192
193 :param years: The number of years
194 :param months: The number of months
195 :param weeks: The number of weeks
196 :param days: The number of days
197 """
198 dt = add_duration(
199 date(self.year, self.month, self.day),
200 years=years,
201 months=months,
202 weeks=weeks,
203 days=days,
204 )
205
206 return self.__class__(dt.year, dt.month, dt.day)
207
208 def subtract(
209 self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0

Callers 4

subtractMethod · 0.95
_add_timedeltaMethod · 0.95
nextMethod · 0.95
averageMethod · 0.95

Calls 2

add_durationFunction · 0.90
dateFunction · 0.85

Tested by

no test coverage detected