http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10416
Revision: 10416 Author: multichill Date: 2012-06-23 16:10:55 +0000 (Sat, 23 Jun 2012) Log Message: ----------- Set self._editTime to None in the page object if it has not been fetched yet.
Add option to get the editTime() of a page object as a datetime object.
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2012-06-23 06:13:55 UTC (rev 10415) +++ trunk/pywikipedia/wikipedia.py 2012-06-23 16:10:55 UTC (rev 10416) @@ -418,7 +418,7 @@ self._permalink = None self._userName = None self._ipedit = None - self._editTime = '0' + self._editTime = None self._startTime = '0' # For the Flagged Revisions MediaWiki extension self._revisionId = None @@ -1260,12 +1260,16 @@ """ return self._ipedit
- def editTime(self): + def editTime(self, datetime=False): """Return timestamp (in MediaWiki format) of last revision to page.
- Returns None if last edit time is unknown. + Returns None unless page was retrieved with getAll() or _getEditPage().
""" + if self._editTime and datetime: + import datetime + return datetime.datetime.strptime(str(self._editTime), '%Y%m%d%H%M%S') + return self._editTime
def previousRevision(self):
pywikipedia-svn@lists.wikimedia.org