Last modified: 2014-10-09 08:20:58 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T73124, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 71124 - Add ability to add/subtract months to/from pywikibot.Timestamp
Add ability to add/subtract months to/from pywikibot.Timestamp
Status: NEW
Product: Pywikibot
Classification: Unclassified
General (Other open bugs)
core-(2.0)
All All
: Unprioritized enhancement
: ---
Assigned To: Pywikipedia bugs
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2014-09-22 16:54 UTC by xqt
Modified: 2014-10-09 08:20 UTC (History)
3 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description xqt 2014-09-22 16:54:45 UTC
mw is able to calculate with parser variable #time e.g. to add or subtract months to the given time. python does not support it with standard libs and dateutils is not part of the framework. On the other hand it would be great to have such a feature calculating months with Timestamps.
Comment 1 Maarten Dammers 2014-09-22 20:30:33 UTC
Timestamp is a subclass of datetime.datetime. Can't we just use timedelta?

https://docs.python.org/2/library/datetime.html#timedelta-objects

This is what I did in newitem.py or do you want to do something else?
Comment 2 xqt 2014-10-09 08:20:58 UTC
The problem is that months have different days between 28 an 31. Adding 1 month to 7th September should result in 7th October. Adding 7th October should give 7th November as result. dateutils does it. The highest timedelta resolution is "days" not "months". We could use constants from calendar module to implement it. I need it to calculate log entries. mw is able to calculate time stamps by adding months and years, whereas datetime objects aren't able to.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links