本文整理汇总了Python中pycalendar.datetime.DateTime.getPosixTime方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.getPosixTime方法的具体用法?Python DateTime.getPosixTime怎么用?Python DateTime.getPosixTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.datetime.DateTime
的用法示例。
在下文中一共展示了DateTime.getPosixTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testCachePreserveOnAdjustment
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import getPosixTime [as 别名]
def testCachePreserveOnAdjustment(self):
# UTC first
dt = DateTime(2012, 6, 7, 12, 0, 0, Timezone(tzid="utc"))
dt.getPosixTime()
# check existing cache is complete
self.assertTrue(dt.mPosixTimeCached)
self.assertNotEqual(dt.mPosixTime, 0)
self.assertEqual(dt.mTZOffset, None)
# duplicate preserves cache details
dt2 = dt.duplicate()
self.assertTrue(dt2.mPosixTimeCached)
self.assertEqual(dt2.mPosixTime, dt.mPosixTime)
self.assertEqual(dt2.mTZOffset, dt.mTZOffset)
# adjust preserves cache details
dt2.adjustToUTC()
self.assertTrue(dt2.mPosixTimeCached)
self.assertEqual(dt2.mPosixTime, dt.mPosixTime)
self.assertEqual(dt2.mTZOffset, dt.mTZOffset)
# Now timezone
tzdata = """BEGIN:VCALENDAR
CALSCALE:GREGORIAN
PRODID:-//calendarserver.org//Zonal//EN
VERSION:2.0
BEGIN:VTIMEZONE
TZID:America/Pittsburgh
BEGIN:STANDARD
DTSTART:18831118T120358
RDATE:18831118T120358
TZNAME:EST
TZOFFSETFROM:-045602
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19180331T020000
RRULE:FREQ=YEARLY;UNTIL=19190330T070000Z;BYDAY=-1SU;BYMONTH=3
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19181027T020000
RRULE:FREQ=YEARLY;UNTIL=19191026T060000Z;BYDAY=-1SU;BYMONTH=10
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:STANDARD
DTSTART:19200101T000000
RDATE:19200101T000000
RDATE:19420101T000000
RDATE:19460101T000000
RDATE:19670101T000000
TZNAME:EST
TZOFFSETFROM:-0500
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19200328T020000
RDATE:19200328T020000
RDATE:19740106T020000
RDATE:19750223T020000
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19201031T020000
RDATE:19201031T020000
RDATE:19450930T020000
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19210424T020000
RRULE:FREQ=YEARLY;UNTIL=19410427T070000Z;BYDAY=-1SU;BYMONTH=4
TZNAME:EDT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:STANDARD
DTSTART:19210925T020000
RRULE:FREQ=YEARLY;UNTIL=19410928T060000Z;BYDAY=-1SU;BYMONTH=9
TZNAME:EST
TZOFFSETFROM:-0400
TZOFFSETTO:-0500
END:STANDARD
BEGIN:DAYLIGHT
DTSTART:19420209T020000
RDATE:19420209T020000
TZNAME:EWT
TZOFFSETFROM:-0500
TZOFFSETTO:-0400
END:DAYLIGHT
BEGIN:DAYLIGHT
#.........这里部分代码省略.........