本文整理汇总了Python中pycalendar.datetime.DateTime.adjustToUTC方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.adjustToUTC方法的具体用法?Python DateTime.adjustToUTC怎么用?Python DateTime.adjustToUTC使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.datetime.DateTime
的用法示例。
在下文中一共展示了DateTime.adjustToUTC方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: VToDo
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import adjustToUTC [as 别名]
#.........这里部分代码省略.........
# Get PERCENT-COMPLETE
self.mPercentComplete = self.loadValueInteger(definitions.cICalProperty_PERCENT_COMPLETE)
# Get COMPLETED
temp = self.loadValueDateTime(definitions.cICalProperty_COMPLETED)
self.mHasCompleted = temp is not None
if self.mHasCompleted:
self.mCompleted = temp
def validate(self, doFix=False):
"""
Validate the data in this component and optionally fix any problems, else raise. If
loggedProblems is not None it must be a C{list} and problem descriptions are appended
to that.
"""
fixed, unfixed = super(VToDo, self).validate(doFix)
# Extra constraint: only one of DUE or DURATION
if self.hasProperty(definitions.cICalProperty_DUE) and self.hasProperty(definitions.cICalProperty_DURATION):
# Fix by removing the DURATION
logProblem = "[%s] Properties must not both be present: %s, %s" % (
self.getType(),
definitions.cICalProperty_DUE,
definitions.cICalProperty_DURATION,
)
if doFix:
self.removeProperties(definitions.cICalProperty_DURATION)
fixed.append(logProblem)
else:
unfixed.append(logProblem)
# Extra constraint: DTSTART must be present if DURATION is present
if self.hasProperty(definitions.cICalProperty_DURATION) and not self.hasProperty(definitions.cICalProperty_DTSTART):
# Cannot fix this one
logProblem = "[%s] Property must be present: %s with %s" % (
self.getType(),
definitions.cICalProperty_DTSTART,
definitions.cICalProperty_DURATION,
)
unfixed.append(logProblem)
return fixed, unfixed
# Editing
def editStatus(self, status):
# Only if it is different
if self.mStatus != status:
# Updated cached values
self.mStatus = status
# Remove existing STATUS & COMPLETED items
self.removeProperties(definitions.cICalProperty_STATUS)
self.removeProperties(definitions.cICalProperty_COMPLETED)
self.mHasCompleted = False
# Now create properties
value = None
if status == definitions.eStatus_VToDo_NeedsAction:
value = definitions.cICalProperty_STATUS_NEEDS_ACTION
if status == definitions.eStatus_VToDo_Completed:
value = definitions.cICalProperty_STATUS_COMPLETED
# Add the completed item
self.mCompleted.setNowUTC()
self.mHasCompleted = True
prop = Property(definitions.cICalProperty_STATUS_COMPLETED, self.mCompleted)
self.addProperty(prop)
elif status == definitions.eStatus_VToDo_InProcess:
value = definitions.cICalProperty_STATUS_IN_PROCESS
elif status == definitions.eStatus_VToDo_Cancelled:
value = definitions.cICalProperty_STATUS_CANCELLED
prop = Property(definitions.cICalProperty_STATUS, value)
self.addProperty(prop)
def editCompleted(self, completed):
# Remove existing COMPLETED item
self.removeProperties(definitions.cICalProperty_COMPLETED)
self.mHasCompleted = False
# Always UTC
self.mCompleted = completed.duplicate()
self.mCompleted.adjustToUTC()
self.mHasCompleted = True
prop = Property(definitions.cICalProperty_STATUS_COMPLETED, self.mCompleted)
self.addProperty(prop)
def sortedPropertyKeyOrder(self):
return (
definitions.cICalProperty_UID,
definitions.cICalProperty_RECURRENCE_ID,
definitions.cICalProperty_DTSTART,
definitions.cICalProperty_DURATION,
definitions.cICalProperty_DUE,
definitions.cICalProperty_COMPLETED,
)