http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11471
Revision: 11471 Author: legoktm Date: 2013-04-27 11:17:54 +0000 (Sat, 27 Apr 2013) Log Message: ----------- Add two new methods to pywikibot.Timestamp: toISOformat, and totimestampformat
Modified Paths: -------------- branches/rewrite/pywikibot/__init__.py
Modified: branches/rewrite/pywikibot/__init__.py =================================================================== --- branches/rewrite/pywikibot/__init__.py 2013-04-27 09:56:49 UTC (rev 11470) +++ branches/rewrite/pywikibot/__init__.py 2013-04-27 11:17:54 UTC (rev 11471) @@ -55,9 +55,17 @@ """Convert the internal MediaWiki timestamp format to a Timestamp object.""" return cls.strptime(ts, cls.mediawikiTSFormat)
+ def toISOformat(self): + """Converts the Timestamp object to an ISO 8601 timestamp""" + return self.strftime(self.ISO8601Format) + + def totimestampformat(self): + """Converts the Timestamp object to the internal MediaWiki timestamp format.""" + return self.strftime(self.mediawikiTSFormat) + def __str__(self): """Return a string format recognized by the API""" - return self.strftime(self.ISO8601Format) + return self.toISOformat()
def __add__(self, other): newdt = datetime.datetime.__add__(self, other)
pywikipedia-svn@lists.wikimedia.org