本文整理匯總了Python中pywikibot.Timestamp.fromtimestampformat方法的典型用法代碼示例。如果您正苦於以下問題:Python Timestamp.fromtimestampformat方法的具體用法?Python Timestamp.fromtimestampformat怎麽用?Python Timestamp.fromtimestampformat使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類pywikibot.Timestamp
的用法示例。
在下文中一共展示了Timestamp.fromtimestampformat方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_instantiate_from_instance
# 需要導入模塊: from pywikibot import Timestamp [as 別名]
# 或者: from pywikibot.Timestamp import fromtimestampformat [as 別名]
def test_instantiate_from_instance(self):
"""Test passing instance to factory methods works."""
t1 = Timestamp.utcnow()
self.assertIsNot(t1, Timestamp.fromISOformat(t1))
self.assertEqual(t1, Timestamp.fromISOformat(t1))
self.assertIsInstance(Timestamp.fromISOformat(t1), Timestamp)
self.assertIsNot(t1, Timestamp.fromtimestampformat(t1))
self.assertEqual(t1, Timestamp.fromtimestampformat(t1))
self.assertIsInstance(Timestamp.fromtimestampformat(t1), Timestamp)
示例2: test_mediawiki_format
# 需要導入模塊: from pywikibot import Timestamp [as 別名]
# 或者: from pywikibot.Timestamp import fromtimestampformat [as 別名]
def test_mediawiki_format(self):
t1 = T.utcnow()
ts1 = t1.totimestampformat()
t2 = T.fromtimestampformat(ts1)
ts2 = t2.totimestampformat()
# MediaWiki timestamp format doesn't include microseconds
self.assertNotEqual(t1, t2)
t1 = t1.replace(microsecond=0)
self.assertEqual(t1, t2)
self.assertEqual(ts1, ts2)