本文整理汇总了Python中pycalendar.datetime.DateTime.setWeekNo方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.setWeekNo方法的具体用法?Python DateTime.setWeekNo怎么用?Python DateTime.setWeekNo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.datetime.DateTime
的用法示例。
在下文中一共展示了DateTime.setWeekNo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testSetWeekNo
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import setWeekNo [as 别名]
def testSetWeekNo(self):
dt = DateTime(2013, 1, 1, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 1)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2013, 1, 1, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)
dt = DateTime(2013, 1, 1, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 1)
dt.setWeekNo(2)
self.assertEqual(dt, DateTime(2013, 1, 8, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 2)
dt = DateTime(2013, 1, 8, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 2)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2013, 1, 1, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)
dt = DateTime(2014, 1, 7, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 2)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2013, 12, 31, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)
dt = DateTime(2012, 12, 31, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 1)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2012, 12, 31, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)
dt = DateTime(2016, 1, 1, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 53)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2016, 1, 8, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)
dt.setWeekNo(2)
self.assertEqual(dt, DateTime(2016, 1, 15, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 2)
dt = DateTime(2016, 1, 8, 0, 0, 0, tzid=Timezone(utc=True))
self.assertEqual(dt.getWeekNo(), 1)
dt.setWeekNo(1)
self.assertEqual(dt, DateTime(2016, 1, 8, 0, 0, 0, tzid=Timezone(utc=True)))
self.assertEqual(dt.getWeekNo(), 1)