本文整理汇总了Python中pycalendar.datetime.DateTime.isDateOnly方法的典型用法代码示例。如果您正苦于以下问题:Python DateTime.isDateOnly方法的具体用法?Python DateTime.isDateOnly怎么用?Python DateTime.isDateOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pycalendar.datetime.DateTime
的用法示例。
在下文中一共展示了DateTime.isDateOnly方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ComponentRecur
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import isDateOnly [as 别名]
class ComponentRecur(Component):
propertyCardinality_STATUS_Fix = (
definitions.cICalProperty_STATUS,
)
@staticmethod
def mapKey(uid, rid=None):
if uid:
result = "u:" + uid
if rid is not None:
result += rid
return result
else:
return None
@staticmethod
def sort_by_dtstart_allday(e1, e2):
if e1.self.mStart.isDateOnly() and e2.self.mStart.isDateOnly():
return e1.self.mStart < e2.self.mStart
elif e1.self.mStart.isDateOnly():
return True
elif (e2.self.mStart.isDateOnly()):
return False
elif e1.self.mStart == e2.self.mStart:
if e1.self.mEnd == e2.self.mEnd:
# Put ones created earlier in earlier columns in day view
return e1.self.mStamp < e2.self.mStamp
else:
# Put ones that end later in earlier columns in day view
return e1.self.mEnd > e2.self.mEnd
else:
return e1.self.mStart < e2.self.mStart
@staticmethod
def sort_by_dtstart(e1, e2):
if e1.self.mStart == e2.self.mStart:
if (
e1.self.mStart.isDateOnly() and e2.self.mStart.isDateOnly() or
not e1.self.mStart.isDateOnly() and not e2.self.mStart.isDateOnly()
):
return False
else:
return e1.self.mStart.isDateOnly()
else:
return e1.self.mStart < e2.self.mStart
def __init__(self, parent=None):
super(ComponentRecur, self).__init__(parent=parent)
self.mMaster = self
self.mMapKey = None
self.mSummary = None
self.mStamp = DateTime()
self.mHasStamp = False
self.mStart = DateTime()
self.mHasStart = False
self.mEnd = DateTime()
self.mHasEnd = False
self.mDuration = False
self.mHasRecurrenceID = False
self.mAdjustFuture = False
self.mAdjustPrior = False
self.mRecurrenceID = None
self.mRecurrences = None
# This is a special check we do only for STATUS due to a calendarserver bug
self.cardinalityChecks += (
self.check_cardinality_STATUS_Fix,
)
def duplicate(self, parent=None):
other = super(ComponentRecur, self).duplicate(parent=parent)
# Special determination of master
other.mMaster = self.mMaster if self.recurring() else self
other.mMapKey = self.mMapKey
other.mSummary = self.mSummary
if (self.mStamp is not None):
other.mStamp = self.mStamp.duplicate()
other.mHasStamp = self.mHasStamp
other.mStart = self.mStart.duplicate()
other.mHasStart = self.mHasStart
other.mEnd = self.mEnd.duplicate()
other.mHasEnd = self.mHasEnd
other.mDuration = self.mDuration
other.mHasRecurrenceID = self.mHasRecurrenceID
other.mAdjustFuture = self.mAdjustFuture
other.mAdjustPrior = self.mAdjustPrior
if self.mRecurrenceID is not None:
other.mRecurrenceID = self.mRecurrenceID.duplicate()
#.........这里部分代码省略.........
示例2: VFreeBusy
# 需要导入模块: from pycalendar.datetime import DateTime [as 别名]
# 或者: from pycalendar.datetime.DateTime import isDateOnly [as 别名]
class VFreeBusy(Component):
propertyCardinality_1 = (
definitions.cICalProperty_DTSTAMP,
definitions.cICalProperty_UID,
)
propertyCardinality_0_1 = (
definitions.cICalProperty_CONTACT,
definitions.cICalProperty_DTSTART,
definitions.cICalProperty_DTEND,
definitions.cICalProperty_ORGANIZER,
definitions.cICalProperty_URL,
)
propertyValueChecks = ICALENDAR_VALUE_CHECKS
def __init__(self, parent=None):
super(VFreeBusy, self).__init__(parent=parent)
self.mStart = DateTime()
self.mHasStart = False
self.mEnd = DateTime()
self.mHasEnd = False
self.mDuration = False
self.mCachedBusyTime = False
self.mSpanPeriod = None
self.mBusyTime = None
def duplicate(self, parent=None):
other = super(VFreeBusy, self).duplicate(parent=parent)
other.mStart = self.mStart.duplicate()
other.mHasStart = self.mHasStart
other.mEnd = self.mEnd.duplicate()
other.mHasEnd = self.mHasEnd
other.mDuration = self.mDuration
other.mCachedBusyTime = False
other.mBusyTime = None
return other
def getType(self):
return definitions.cICalComponent_VFREEBUSY
def getMimeComponentName(self):
return itipdefinitions.cICalMIMEComponent_VFREEBUSY
def finalise(self):
# Do inherited
super(VFreeBusy, self).finalise()
# Get DTSTART
temp = self.loadValueDateTime(definitions.cICalProperty_DTSTART)
self.mHasStart = temp is not None
if self.mHasStart:
self.mStart = temp
# Get DTEND
temp = self.loadValueDateTime(definitions.cICalProperty_DTEND)
if temp is None:
# Try DURATION instead
temp = self.loadValueDuration(definitions.cICalProperty_DURATION)
if temp is not None:
self.mEnd = self.mStart + temp
self.mDuration = True
else:
# Force end to start, which will then be fixed to sensible
# value later
self.mEnd = self.mStart
else:
self.mHasEnd = True
self.mDuration = False
self.mEnd = temp
def fixStartEnd(self):
# End is always greater than start if start exists
if self.mHasStart and self.mEnd <= self.mStart:
# Use the start
self.mEnd = self.mStart.duplicate()
self.mDuration = False
# Adjust to appropiate non-inclusive end point
if self.mStart.isDateOnly():
self.mEnd.offsetDay(1)
# For all day events it makes sense to use duration
self.mDuration = True
else:
# Use end of current day
self.mEnd.offsetDay(1)
self.mEnd.setHHMMSS(0, 0, 0)
def getStart(self):
return self.mStart
#.........这里部分代码省略.........