本文整理汇总了Python中pycalendar.datetime.DateTime.setMinutes方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.setMinutes方法的具体用法?Python DateTime.setMinutes怎么用?Python DateTime.setMinutes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.datetime.DateTime
的用法示例。
在下文中一共展示了DateTime.setMinutes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: datetimeForYear
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import setMinutes [as 别名]
def datetimeForYear(self, year):
"""
Given a specific year, determine the actual date/time of the transition
@param year: the year to determine the transition for
@type year: C{int}
@return: C{tuple} of L{DateTime} and C{str} (which is the special
tzdata mode character
"""
# Create a floating date-time
dt = DateTime()
# Setup base year/month/day
dt.setYear(year)
dt.setMonth(Rule.MONTH_NAME_TO_POS[self.inMonth])
dt.setDay(1)
# Setup base hours/minutes
splits = self.atTime.split(":")
if len(splits) == 1:
splits.append("0")
assert len(splits) == 2, "atTime format is wrong: %s, %s" % (self.atTime, self,)
hours = int(splits[0])
if len(splits[1]) > 2:
minutes = int(splits[1][:2])
special = splits[1][2:]
else:
minutes = int(splits[1])
special = ""
# Special case for 24:00
if hours == 24 and minutes == 0:
dt.setHours(23)
dt.setMinutes(59)
dt.setSeconds(59)
else:
dt.setHours(hours)
dt.setMinutes(minutes)
# Now determine the actual start day
if self.onDay in Rule.LASTDAY_NAME_TO_DAY:
dt.setDayOfWeekInMonth(-1, Rule.LASTDAY_NAME_TO_DAY[self.onDay])
elif self.onDay.find(">=") != -1:
splits = self.onDay.split(">=")
dt.setNextDayOfWeek(int(splits[1]), Rule.DAY_NAME_TO_DAY[splits[0]])
else:
try:
day = int(self.onDay)
dt.setDay(day)
except:
assert False, "onDay value is not recognized: %s" % (self.onDay,)
return dt, special