[CalendarServer-changes] [13935] PyCalendar/trunk/src/pycalendar/instances.py
source_changes at macosforge.org
source_changes at macosforge.org
Wed Sep 3 08:01:12 PDT 2014
Revision: 13935
http://trac.calendarserver.org//changeset/13935
Author: cdaboo at apple.com
Date: 2014-09-03 08:01:12 -0700 (Wed, 03 Sep 2014)
Log Message:
-----------
Simple tool to expand an rrule.
Added Paths:
-----------
PyCalendar/trunk/src/pycalendar/instances.py
Added: PyCalendar/trunk/src/pycalendar/instances.py
===================================================================
--- PyCalendar/trunk/src/pycalendar/instances.py (rev 0)
+++ PyCalendar/trunk/src/pycalendar/instances.py 2014-09-03 15:01:12 UTC (rev 13935)
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+##
+# Copyright (c) 2014 Cyrus Daboo. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from __future__ import print_function
+from pycalendar.datetime import DateTime
+from pycalendar.icalendar.recurrence import Recurrence
+from pycalendar.period import Period
+import sys
+
+def instances(start, rrule):
+ """
+ Expand an RRULE.
+ """
+
+ recur = Recurrence()
+ recur.parse(rrule)
+ start = DateTime.parseText(start)
+ end = start.duplicate()
+ end.offsetYear(100)
+ items = []
+ range = Period(start, end)
+ recur.expand(start, range, items)
+ print("DTSTART:{}".format(start))
+ print("RRULE:{}".format(rrule))
+ print("Instances: {}".format(", ".join(map(str, items))))
+
+
+if __name__ == '__main__':
+
+ instances(sys.argv[1], sys.argv[2])
Property changes on: PyCalendar/trunk/src/pycalendar/instances.py
___________________________________________________________________
Added: svn:executable
+ *
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140903/ad976584/attachment.html>
More information about the calendarserver-changes
mailing list