本文整理汇总了Python中pycalendar.datetime.DateTime类的典型用法代码示例。如果您正苦于以下问题:Python DateTime类的具体用法?Python DateTime怎么用?Python DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DateTime类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _deserialize
def _deserialize(self, data):
"""
Convert a JSON compatible serialization of this object into the actual object.
"""
self.start = DateTime.parseText(data["start"]) if data["start"] else None
self.end = DateTime.parseText(data["end"]) if data["end"] else None
self.tzinfo = Timezone(tzid=data["tzinfo"]) if data["tzinfo"] else None
开发者ID:eventable,项目名称:CalendarServer,代码行数:7,代码来源:filter.py
示例2: actionExpand
def actionExpand(self, request, tzid):
"""
Expand a timezone within specified start/end dates.
"""
if set(request.args.keys()) - set(("start", "end",)):
self.problemReport("invalid-action", "Invalid request-URI query parameters", responsecode.BAD_REQUEST)
start = request.args.get("start", ())
if len(start) == 0:
self.problemReport("invalid-start", "Missing start request-URI query parameter", responsecode.BAD_REQUEST)
if len(start) > 1:
self.problemReport("invalid-start", "Too many start request-URI query parameters", responsecode.BAD_REQUEST)
elif len(start) == 1:
try:
if len(start[0]) != 20:
raise ValueError()
start = DateTime.parseText(start[0], fullISO=True)
except ValueError:
self.problemReport("invalid-start", "Invalid start request-URI query parameter value", responsecode.BAD_REQUEST)
end = request.args.get("end", ())
if len(end) == 0:
self.problemReport("invalid-end", "Missing end request-URI query parameter", responsecode.BAD_REQUEST)
if len(end) > 1:
self.problemReport("invalid-end", "Too many end request-URI query parameters", responsecode.BAD_REQUEST)
elif len(end) == 1:
try:
if len(end[0]) != 20:
raise ValueError()
end = DateTime.parseText(end[0], fullISO=True)
except ValueError:
self.problemReport("invalid-end", "Invalid end request-URI query parameter value", responsecode.BAD_REQUEST)
if end <= start:
self.problemReport("invalid-end", "Invalid end request-URI query parameter value - earlier than start", responsecode.BAD_REQUEST)
tzdata = self.timezones.getTimezone(tzid)
if tzdata is None:
self.problemReport("tzid-not-found", "Time zone identifier not found", responsecode.NOT_FOUND)
# Now do the expansion (but use a cache to avoid re-calculating TZs)
observances = self.expandcache.get((tzid, start, end), None)
if observances is None:
observances = tzexpandlocal(tzdata, start, end, utc_onset=True)
self.expandcache[(tzid, start, end)] = observances
# Turn into JSON
result = {
"dtstamp": self.timezones.dtstamp,
"tzid": tzid,
"observances": [
{
"name": name,
"onset": onset.getXMLText(),
"utc-offset-from": utc_offset_from,
"utc-offset-to": utc_offset_to,
} for onset, utc_offset_from, utc_offset_to, name in observances
],
}
return JSONResponse(responsecode.OK, result, pretty=config.TimezoneService.PrettyPrintJSON)
开发者ID:eventable,项目名称:CalendarServer,代码行数:60,代码来源:timezonestdservice.py
示例3: test_calendar_query_bogus_timezone_id
def test_calendar_query_bogus_timezone_id(self):
"""
Partial retrieval of events by time range.
(CalDAV-access-09, section 7.6.1)
"""
TimezoneCache.create()
self.addCleanup(TimezoneCache.clear)
calendar_properties = (
davxml.GETETag(),
caldavxml.CalendarData(),
)
query_timerange = caldavxml.TimeRange(
start="%04d1001T000000Z" % (DateTime.getToday().getYear(),),
end="%04d1101T000000Z" % (DateTime.getToday().getYear(),),
)
query = caldavxml.CalendarQuery(
davxml.PropertyContainer(*calendar_properties),
caldavxml.Filter(
caldavxml.ComponentFilter(
caldavxml.ComponentFilter(
query_timerange,
name="VEVENT",
),
name="VCALENDAR",
),
),
caldavxml.TimeZoneID.fromString("bogus"),
)
result = yield self.calendar_query(query, got_xml=None, expected_code=responsecode.FORBIDDEN)
self.assertTrue("valid-timezone" in result)
开发者ID:eventable,项目名称:CalendarServer,代码行数:34,代码来源:test_calendarquery.py
示例4: doIt
def doIt(self, txn):
uid = raw_input("Owner UID/Name: ")
start = raw_input("Start Time (UTC YYYYMMDDTHHMMSSZ or YYYYMMDD): ")
if len(start) == 8:
start += "T000000Z"
end = raw_input("End Time (UTC YYYYMMDDTHHMMSSZ or YYYYMMDD): ")
if len(end) == 8:
end += "T000000Z"
try:
start = DateTime.parseText(start)
except ValueError:
print("Invalid start value")
returnValue(None)
try:
end = DateTime.parseText(end)
except ValueError:
print("Invalid end value")
returnValue(None)
timerange = caldavxml.TimeRange(start=start.getText(), end=end.getText())
home = yield txn.calendarHomeWithUID(uid)
if home is None:
print("Could not find calendar home")
returnValue(None)
yield self.eventsForEachCalendar(home, uid, timerange)
开发者ID:eventable,项目名称:CalendarServer,代码行数:28,代码来源:dbinspect.py
示例5: _addEvent
def _addEvent(self):
if not self._client.started:
return succeed(None)
calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")
while calendars:
calendar = self.random.choice(calendars)
calendars.remove(calendar)
# Copy the template event and fill in some of its fields
# to make a new event to create on the calendar.
vcalendar = self._eventTemplate.duplicate()
vevent = vcalendar.mainComponent()
uid = str(uuid4())
dtstart = self._eventStartDistribution.sample()
dtend = dtstart + Duration(seconds=self._eventDurationDistribution.sample())
vevent.replaceProperty(Property("CREATED", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTART", dtstart))
vevent.replaceProperty(Property("DTEND", dtend))
vevent.replaceProperty(Property("UID", uid))
rrule = self._recurrenceDistribution.sample()
if rrule is not None:
vevent.addProperty(Property(None, None, None, pycalendar=rrule))
href = '%s%s.ics' % (calendar.url, uid)
d = self._client.addEvent(href, vcalendar)
return self._newOperation("create", d)
开发者ID:eventable,项目名称:CalendarServer,代码行数:30,代码来源:profiles.py
示例6: testRoundtrip
def testRoundtrip(self):
data1 = (
"20110102",
"20110103T121212",
"20110103T121212Z",
"00010102",
"00010103T121212",
"00010103T121212Z",
)
data2 = (
("20110102", "20110102"),
("2011-01-02", "20110102"),
("20110103T121212", "20110103T121212"),
("2011-01-03T12:12:12", "20110103T121212"),
("20110103T121212Z", "20110103T121212Z"),
("2011-01-03T12:12:12Z", "20110103T121212Z"),
("20110103T121212+0100", "20110103T121212+0100"),
("2011-01-03T12:12:12-0500", "20110103T121212-0500"),
("20110103T121212,123", "20110103T121212"),
("2011-01-03T12:12:12,123", "20110103T121212"),
("20110103T121212,123Z", "20110103T121212Z"),
("2011-01-03T12:12:12,123Z", "20110103T121212Z"),
("20110103T121212,123+0100", "20110103T121212+0100"),
("2011-01-03T12:12:12,123-0500", "20110103T121212-0500"),
)
for item in data1:
dt = DateTime.parseText(item, False)
self.assertEqual(dt.getText(), item, "Failed on: %s" % (item,))
for item, result in data2:
dt = DateTime.parseText(item, True)
self.assertEqual(dt.getText(), result, "Failed on: %s" % (item,))
开发者ID:eventable,项目名称:PyCalendar,代码行数:35,代码来源:test_datetime.py
示例7: test_freebusy
def test_freebusy(self):
"""
Test that action=component works.
"""
yield self.createShare("user01", "puser01")
calendar1 = yield self.calendarUnderTest(txn=self.theTransactionUnderTest(0), home="user01", name="calendar")
yield calendar1.createCalendarObjectWithName("1.ics", Component.fromString(self.caldata1))
yield self.commitTransaction(0)
fbstart = "{now:04d}0102T000000Z".format(**self.nowYear)
fbend = "{now:04d}0103T000000Z".format(**self.nowYear)
shared = yield self.calendarUnderTest(txn=self.theTransactionUnderTest(1), home="puser01", name="shared-calendar")
fbinfo = FreebusyQuery.FBInfo([], [], [])
timerange = Period(DateTime.parseText(fbstart), DateTime.parseText(fbend))
organizer = recipient = (yield calendarUserFromCalendarUserAddress("mailto:[email protected]", self.theTransactionUnderTest(1)))
freebusy = FreebusyQuery(organizer=organizer, recipient=recipient, timerange=timerange)
matchtotal = (yield freebusy.generateFreeBusyInfo([shared, ], fbinfo))
self.assertEqual(matchtotal, 1)
self.assertEqual(fbinfo[0], [Period.parseText("{now:04d}0102T140000Z/PT1H".format(**self.nowYear)), ])
self.assertEqual(len(fbinfo[1]), 0)
self.assertEqual(len(fbinfo[2]), 0)
yield self.commitTransaction(1)
开发者ID:eventable,项目名称:CalendarServer,代码行数:28,代码来源:test_conduit.py
示例8: __init__
def __init__(self, parent=None):
super(VAlarm, self).__init__(parent=parent)
self.mAction = definitions.eAction_VAlarm_Display
self.mTriggerAbsolute = False
self.mTriggerOnStart = True
self.mTriggerOn = DateTime()
# Set duration default to 1 hour
self.mTriggerBy = Duration()
self.mTriggerBy.setDuration(60 * 60)
# Does not repeat by default
self.mRepeats = 0
self.mRepeatInterval = Duration()
self.mRepeatInterval.setDuration(5 * 60) # Five minutes
# Status
self.mStatusInit = False
self.mAlarmStatus = definitions.eAlarm_Status_Pending
self.mLastTrigger = DateTime()
self.mNextTrigger = DateTime()
self.mDoneCount = 0
# Create action data
self.mActionData = VAlarm.VAlarmDisplay("")
开发者ID:eventable,项目名称:PyCalendar,代码行数:27,代码来源:valarm.py
示例9: _initEvent
def _initEvent(self):
if not self._client.started:
return succeed(None)
# If it already exists, don't re-create
calendar = self._calendarsOfType(caldavxml.calendar, "VEVENT")[0]
if calendar.events:
events = [event for event in calendar.events.values() if event.url.endswith("event_to_update.ics")]
if events:
return succeed(None)
# Copy the template event and fill in some of its fields
# to make a new event to create on the calendar.
vcalendar = self._eventTemplate.duplicate()
vevent = vcalendar.mainComponent()
uid = str(uuid4())
dtstart = self._eventStartDistribution.sample()
dtend = dtstart + Duration(seconds=self._eventDurationDistribution.sample())
vevent.replaceProperty(Property("CREATED", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTART", dtstart))
vevent.replaceProperty(Property("DTEND", dtend))
vevent.replaceProperty(Property("UID", uid))
rrule = self._recurrenceDistribution.sample()
if rrule is not None:
vevent.addProperty(Property(None, None, None, pycalendar=rrule))
href = '%s%s' % (calendar.url, "event_to_update.ics")
d = self._client.addEvent(href, vcalendar)
return self._newOperation("create", d)
开发者ID:eventable,项目名称:CalendarServer,代码行数:31,代码来源:profiles.py
示例10: doPOSTExpand
def doPOSTExpand(self, request):
"""
Expand a timezone within specified start/end dates.
"""
tzid = request.args.get("tzid", ())
if len(tzid) != 1:
raise HTTPError(ErrorResponse(
responsecode.BAD_REQUEST,
(calendarserver_namespace, "valid-timezone"),
"Invalid tzid query parameter",
))
tzid = tzid[0]
try:
tzdata = readTZ(tzid)
except TimezoneException:
raise HTTPError(ErrorResponse(
responsecode.NOT_FOUND,
(calendarserver_namespace, "timezone-available"),
"Timezone not found",
))
try:
start = request.args.get("start", ())
if len(start) != 1:
raise ValueError()
start = DateTime.parseText(start[0])
except ValueError:
raise HTTPError(ErrorResponse(
responsecode.BAD_REQUEST,
(calendarserver_namespace, "valid-start-date"),
"Invalid start query parameter",
))
try:
end = request.args.get("end", ())
if len(end) != 1:
raise ValueError()
end = DateTime.parseText(end[0])
if end <= start:
raise ValueError()
except ValueError:
raise HTTPError(ErrorResponse(
responsecode.BAD_REQUEST,
(calendarserver_namespace, "valid-end-date"),
"Invalid end query parameter",
))
# Now do the expansion (but use a cache to avoid re-calculating TZs)
observances = self.cache.get((tzid, start, end), None)
if observances is None:
observances = tzexpand(tzdata, start, end)
self.cache[(tzid, start, end)] = observances
# Turn into XML
result = customxml.TZData(
*[customxml.Observance(customxml.Onset(onset), customxml.UTCOffset(utc_offset)) for onset, utc_offset in observances]
)
return XMLResponse(responsecode.OK, result)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:59,代码来源:timezoneservice.py
示例11: _doRefresh
def _doRefresh(tzpath, xmlfile, tzdb, tzvers):
"""
Refresh data from IANA.
"""
print("Downloading latest data from IANA")
if tzvers:
path = "https://www.iana.org/time-zones/repository/releases/tzdata%s.tar.gz" % (tzvers,)
else:
path = "https://www.iana.org/time-zones/repository/tzdata-latest.tar.gz"
data = urllib.urlretrieve(path)
print("Extract data at: %s" % (data[0]))
rootdir = tempfile.mkdtemp()
zonedir = os.path.join(rootdir, "tzdata")
os.mkdir(zonedir)
with tarfile.open(data[0], "r:gz") as t:
t.extractall(zonedir)
# Get the version from the Makefile
try:
makefile = open(os.path.join(zonedir, "Makefile")).read()
lines = makefile.splitlines()
for line in lines:
if line.startswith("VERSION="):
tzvers = line[8:].strip()
break
except IOError:
pass
if not tzvers:
tzvers = DateTime.getToday().getText()
print("Converting data (version: %s) at: %s" % (tzvers, zonedir,))
startYear = 1800
endYear = DateTime.getToday().getYear() + 10
Calendar.sProdID = "-//calendarserver.org//Zonal//EN"
zonefiles = "northamerica", "southamerica", "europe", "africa", "asia", "australasia", "antarctica", "etcetera", "backward"
parser = tzconvert()
for file in zonefiles:
parser.parse(os.path.join(zonedir, file))
parser.generateZoneinfoFiles(os.path.join(rootdir, "zoneinfo"), startYear, endYear, filterzones=())
print("Copy new zoneinfo to destination: %s" % (tzpath,))
z = FilePath(os.path.join(rootdir, "zoneinfo"))
tz = FilePath(tzpath)
z.copyTo(tz)
print("Updating XML file at: %s" % (xmlfile,))
tzdb.readDatabase()
tzdb.updateDatabase()
print("Current total: %d" % (len(tzdb.timezones),))
print("Total Changed: %d" % (tzdb.changeCount,))
if tzdb.changeCount:
print("Changed:")
for k in sorted(tzdb.changed):
print(" %s" % (k,))
versfile = os.path.join(os.path.dirname(xmlfile), "version.txt")
print("Updating version file at: %s" % (versfile,))
with open(versfile, "w") as f:
f.write(TimezoneCache.IANA_VERSION_PREFIX + tzvers)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:59,代码来源:managetimezones.py
示例12: __init__
def __init__(self, *children, **attributes):
super(CalDAVTimeRangeElement, self).__init__(*children, **attributes)
# One of start or end must be present
if "start" not in attributes and "end" not in attributes:
raise ValueError("One of 'start' or 'end' must be present in CALDAV:time-range")
self.start = DateTime.parseText(attributes["start"]) if "start" in attributes else None
self.end = DateTime.parseText(attributes["end"]) if "end" in attributes else None
开发者ID:nunb,项目名称:calendarserver,代码行数:9,代码来源:caldavxml.py
示例13: __init__
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
开发者ID:eventable,项目名称:PyCalendar,代码行数:10,代码来源:vfreebusy.py
示例14: _invite
def _invite(self):
"""
Try to add a new event, or perhaps remove an
existing attendee from an event.
@return: C{None} if there are no events to play with,
otherwise a L{Deferred} which fires when the attendee
change has been made.
"""
if not self._client.started:
return succeed(None)
# Find calendars which are eligible for invites
calendars = self._calendarsOfType(caldavxml.calendar, "VEVENT")
while calendars:
# Pick one at random from which to try to create an event
# to modify.
calendar = self.random.choice(calendars)
calendars.remove(calendar)
# Copy the template event and fill in some of its fields
# to make a new event to create on the calendar.
vcalendar = self._eventTemplate.duplicate()
vevent = vcalendar.mainComponent()
uid = str(uuid4())
dtstart = self._eventStartDistribution.sample()
dtend = dtstart + Duration(seconds=self._eventDurationDistribution.sample())
vevent.replaceProperty(Property("CREATED", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTAMP", DateTime.getNowUTC()))
vevent.replaceProperty(Property("DTSTART", dtstart))
vevent.replaceProperty(Property("DTEND", dtend))
vevent.replaceProperty(Property("UID", uid))
rrule = self._recurrenceDistribution.sample()
if rrule is not None:
vevent.addProperty(Property(None, None, None, pycalendar=rrule))
vevent.addProperty(self._client._makeSelfOrganizer())
vevent.addProperty(self._client._makeSelfAttendee())
attendees = list(vevent.properties('ATTENDEE'))
for _ignore in range(int(self._inviteeCountDistribution.sample())):
try:
self._addAttendee(vevent, attendees)
except CannotAddAttendee:
self._failedOperation("invite", "Cannot add attendee")
return succeed(None)
href = '%s%s.ics' % (calendar.url, uid)
d = self._client.addInvite(href, vcalendar)
return self._newOperation("invite", d)
开发者ID:eventable,项目名称:CalendarServer,代码行数:53,代码来源:profiles.py
示例15: getEventDetails
def getEventDetails(event):
detail = {}
nowPyDT = DateTime.getNowUTC()
nowDT = datetime.datetime.utcnow()
oneYearInFuture = DateTime.getNowUTC()
oneYearInFuture.offsetDay(365)
component = yield event.component()
mainSummary = component.mainComponent().propertyValue("SUMMARY", u"<no title>")
whenTrashed = event.whenTrashed()
ago = nowDT - whenTrashed
detail["summary"] = mainSummary
detail["whenTrashed"] = agoString(ago)
detail["recoveryID"] = event._resourceID
if component.isRecurring():
detail["recurring"] = True
detail["instances"] = []
instances = component.cacheExpandedTimeRanges(oneYearInFuture)
instances = sorted(instances.instances.values(), key=lambda x: x.start)
limit = 3
count = 0
for instance in instances:
if instance.start >= nowPyDT:
summary = instance.component.propertyValue("SUMMARY", u"<no title>")
location = locationString(instance.component)
tzid = instance.component.getProperty("DTSTART").parameterValue("TZID", None)
dtstart = instance.start
if tzid is not None:
timezone = Timezone(tzid=tzid)
dtstart.adjustTimezone(timezone)
detail["instances"].append(
{
"summary": summary,
"starttime": dtstart.getLocaleDateTime(DateTime.FULLDATE, False, True, dtstart.getTimezoneID()),
"location": location,
}
)
count += 1
limit -= 1
if limit == 0:
break
else:
detail["recurring"] = False
dtstart = component.mainComponent().propertyValue("DTSTART")
detail["starttime"] = dtstart.getLocaleDateTime(DateTime.FULLDATE, False, True, dtstart.getTimezoneID())
detail["location"] = locationString(component.mainComponent())
returnValue(detail)
开发者ID:eventable,项目名称:CalendarServer,代码行数:52,代码来源:util.py
示例16: __init__
def __init__(self, xml_element):
super(TimeRange, self).__init__(xml_element)
if xml_element is None:
return
# One of start or end must be present
if "start" not in xml_element.attributes and "end" not in xml_element.attributes:
raise ValueError("One of 'start' or 'end' must be present in CALDAV:time-range")
self.start = DateTime.parseText(xml_element.attributes["start"]) if "start" in xml_element.attributes else None
self.end = DateTime.parseText(xml_element.attributes["end"]) if "end" in xml_element.attributes else None
self.tzinfo = None
开发者ID:eventable,项目名称:CalendarServer,代码行数:13,代码来源:filter.py
示例17: sort_for_display
def sort_for_display(e1, e2):
s1 = e1.getMaster()
s2 = e2.getMaster()
# Check status first (convert None -> Needs action for tests)
status1 = s1.self.mStatus
status2 = s2.self.mStatus
if status1 == definitions.eStatus_VToDo_None:
status1 = definitions.eStatus_VToDo_NeedsAction
if status2 == definitions.eStatus_VToDo_None:
status2 = definitions.eStatus_VToDo_NeedsAction
if status1 != status2:
# More important ones at the top
return status1 < status2
# At this point the status of each is the same
# If status is cancelled sort by start time
if s1.self.mStatus == definitions.eStatus_VToDo_Cancelled:
# Older ones at the bottom
return s1.mStart > s2.mStart
# If status is completed sort by completion time
if s1.self.mStatus == definitions.eStatus_VToDo_Completed:
# Older ones at the bottom
return s1.self.mCompleted > s2.self.mCompleted
# Check due date exists
if s1.mHasEnd != s2.mHasEnd:
now = DateTime()
now.setToday()
# Ones with due dates after today below ones without due dates
if s1.hasEnd():
return s1.mEnd <= now
elif s2.hasEnd():
return now < s2.mEnd
# Check due dates if present
if s1.mHasEnd:
if s1.mEnd != s2.mEnd:
# Soonest dues dates above later ones
return s1.mEnd < s2.mEnd
# Check priority next
if s1.self.mPriority != s2.self.mPriority:
# Higher priority above lower ones
return s1.self.mPriority < s2.self.mPriority
# Just use start time - older ones at the top
return s1.mStart < s2.mStart
开发者ID:eventable,项目名称:PyCalendar,代码行数:51,代码来源:vtodo.py
示例18: getVToDos
def getVToDos(self, only_due, all_dates, upto_due_date, list):
# Get current date-time less one day to test for completed events during the last day
minusoneday = DateTime()
minusoneday.setNowUTC()
minusoneday.offsetDay(-1)
today = DateTime()
today.setToday()
# Look at each VToDo
for vtodo in self.getComponents(definitions.cICalComponent_VTODO):
# Filter out done (that were complted more than a day ago) or cancelled to dos if required
if only_due:
if vtodo.getStatus() == definitions.eStatus_VToDo_Cancelled:
continue
elif (
(vtodo.getStatus() == definitions.eStatus_VToDo_Completed) and
(not vtodo.hasCompleted() or (vtodo.getCompleted() < minusoneday))
):
continue
# Filter out those with end after chosen date if required
if not all_dates:
if vtodo.hasEnd() and (vtodo.getEnd() > upto_due_date):
continue
elif not vtodo.hasEnd() and (today > upto_due_date):
continue
开发者ID:eventable,项目名称:PyCalendar,代码行数:28,代码来源:calendar.py
示例19: printEventDetails
def printEventDetails(event):
nowPyDT = DateTime.getNowUTC()
nowDT = datetime.datetime.utcnow()
oneYearInFuture = DateTime.getNowUTC()
oneYearInFuture.offsetDay(365)
component = yield event.component()
mainSummary = component.mainComponent().propertyValue("SUMMARY", u"<no title>")
whenTrashed = event.whenTrashed()
ago = nowDT - whenTrashed
print(" Trashed {}:".format(agoString(ago)))
if component.isRecurring():
print(
" \"{}\" (repeating) Recovery ID = {}".format(
mainSummary, event._resourceID
)
)
print(" ...upcoming instances:")
instances = component.cacheExpandedTimeRanges(oneYearInFuture)
instances = sorted(instances.instances.values(), key=lambda x: x.start)
limit = 3
count = 0
for instance in instances:
if instance.start >= nowPyDT:
summary = instance.component.propertyValue("SUMMARY", u"<no title>")
location = locationString(instance.component)
tzid = instance.component.getProperty("DTSTART").parameterValue("TZID", None)
dtstart = instance.start
if tzid is not None:
timezone = Timezone(tzid=tzid)
dtstart.adjustTimezone(timezone)
print(" \"{}\" {} {}".format(summary, startString(dtstart), location))
count += 1
limit -= 1
if limit == 0:
break
if not count:
print(" (none)")
else:
print(
" \"{}\" (non-repeating) Recovery ID = {}".format(
mainSummary, event._resourceID
)
)
dtstart = component.mainComponent().propertyValue("DTSTART")
location = locationString(component.mainComponent())
print(" {} {}".format(startString(dtstart), location))
开发者ID:eventable,项目名称:CalendarServer,代码行数:49,代码来源:trash.py
示例20: __init__
def __init__(self, threshold, past):
"""
@param threshold: the size in bytes that will trigger a split
@type threshold: C{int}
@param past: number of days in the past where the split will occur
@type past: C{int}
"""
self.threshold = threshold
self.past = DateTime.getNowUTC()
self.past.setHHMMSS(0, 0, 0)
self.past.offsetDay(-past)
self.now = DateTime.getNowUTC()
self.now.setHHMMSS(0, 0, 0)
self.now.offsetDay(-1)
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:15,代码来源:icalsplitter.py
注:本文中的pycalendar.datetime.DateTime类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论