jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340632?usp=email )

Change subject: Reuse the timestamp date when calculating year durations
......................................................................

Reuse the timestamp date when calculating year durations

Extract the date once and reuse it for the month adjustment and
subtraction in str2timedelta(). Avoid constructing the same date twice.

Change-Id: I1138c92f35ba5ef925dd75f7efd06ff204786c81
---
M pywikibot/time.py
1 file changed, 2 insertions(+), 1 deletion(-)

Approvals:
  Mahveotm: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/time.py b/pywikibot/time.py
index 942626b..e345f95 100644
--- a/pywikibot/time.py
+++ b/pywikibot/time.py
@@ -481,8 +481,9 @@
         duration *= 12

         if timestamp:
+            date = timestamp.date()
             return pywikibot.date.apply_month_delta(
-                timestamp.date(), month_delta=duration) - timestamp.date()
+                date, month_delta=duration) - date
         return datetime.timedelta(days=days)

     # days, seconds, hours, weeks

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1340632?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I1138c92f35ba5ef925dd75f7efd06ff204786c81
Gerrit-Change-Number: 1340632
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Mahveotm <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to