2016-04-19 | Paul Boddie | file changeset files shortlog | Send REQUEST messages to other attendees when an attendee has created a new recurrence, thus updating the others with the details of the new recurrence together with the originating attendee's attendance details. Extended the tests to propagate such messages and to inspect the results. | freebusy-collections |
paul@716 | 1 | #!/usr/bin/env python |
paul@716 | 2 | |
paul@716 | 3 | """ |
paul@716 | 4 | Increment the hour in a datetime string, wrapping round within any given range. |
paul@716 | 5 | """ |
paul@716 | 6 | |
paul@716 | 7 | import sys |
paul@716 | 8 | |
paul@716 | 9 | try: |
paul@716 | 10 | dt_str = sys.argv[1] |
paul@716 | 11 | first, last = (sys.argv[2:4] + [None, None])[:2] |
paul@716 | 12 | except (IndexError, ValueError): |
paul@716 | 13 | sys.exit(1) |
paul@716 | 14 | |
paul@716 | 15 | if not dt_str: |
paul@716 | 16 | sys.exit(1) |
paul@716 | 17 | |
paul@716 | 18 | try: |
paul@716 | 19 | date_str = dt_str[:9] |
paul@716 | 20 | hour = int(dt_str[9:11]) |
paul@716 | 21 | min_sec_str = dt_str[11:] |
paul@716 | 22 | except ValueError: |
paul@716 | 23 | sys.exit(1) |
paul@716 | 24 | |
paul@716 | 25 | if not first: |
paul@716 | 26 | first = 0 |
paul@716 | 27 | else: |
paul@716 | 28 | first = int(first) |
paul@716 | 29 | |
paul@716 | 30 | if not last: |
paul@716 | 31 | last = 23 |
paul@716 | 32 | else: |
paul@716 | 33 | last = int(last) |
paul@716 | 34 | |
paul@716 | 35 | hour += 1 |
paul@716 | 36 | if hour > last: |
paul@716 | 37 | hour = first |
paul@716 | 38 | |
paul@716 | 39 | print '%s%02d%s' % (date_str, hour, min_sec_str) |
paul@716 | 40 | |
paul@716 | 41 | # vim: tabstop=4 expandtab shiftwidth=4 |