T
tinnews
I have a python script which uses the dateutil module with the
following:-
import sys
import datetime
import icalendar
from dateutil.relativedelta import relativedelta
The section of code which uses relativedelta is as follows:-
#
#
# If the event is a repeating event with a start date in the
# past then we add the repeat interval until we find the next
# occurrence
#
if eventDate < datetime.date.today():
if event.has_key('RRULE'):
freq = event.decoded('RRULE')['FREQ'][0]
if event.decoded('RRULE').has_key('INTERVAL'):
interval = event.decoded('RRULE')['INTERVAL'][0]
else:
interval = 1;
if 'WEEKLY' == freq:
delta = relativedelta(weeks=+interval)
if 'MONTHLY' == freq:
delta = relativedelta(months=+interval)
if 'YEARLY' == freq:
delta = relativedelta(years=+interval)
while eventDate < datetime.date.today():
eventDate += delta
else:
continue # if it's a non-repeating event in the past
It used to work and all I have done meanwhile is to update my xubuntu
system as fixes are released. I'm now getting the error:-
Traceback (most recent call last):
File "/home/chris/bin/calics.py", line 62, in <module>
eventDate += delta
File "/usr/lib/python2.7/dist-packages/dateutil/relativedelta.py", line 261, in __radd__
day = min(calendar.monthrange(year, month)[1],
AttributeError: 'module' object has no attribute 'monthrange'
Have I lost a module somewhere in the updates or has something in
python changed such that my code no longer works as it used to?
Can anyone help diagnose this please.
following:-
import sys
import datetime
import icalendar
from dateutil.relativedelta import relativedelta
The section of code which uses relativedelta is as follows:-
#
#
# If the event is a repeating event with a start date in the
# past then we add the repeat interval until we find the next
# occurrence
#
if eventDate < datetime.date.today():
if event.has_key('RRULE'):
freq = event.decoded('RRULE')['FREQ'][0]
if event.decoded('RRULE').has_key('INTERVAL'):
interval = event.decoded('RRULE')['INTERVAL'][0]
else:
interval = 1;
if 'WEEKLY' == freq:
delta = relativedelta(weeks=+interval)
if 'MONTHLY' == freq:
delta = relativedelta(months=+interval)
if 'YEARLY' == freq:
delta = relativedelta(years=+interval)
while eventDate < datetime.date.today():
eventDate += delta
else:
continue # if it's a non-repeating event in the past
It used to work and all I have done meanwhile is to update my xubuntu
system as fixes are released. I'm now getting the error:-
Traceback (most recent call last):
File "/home/chris/bin/calics.py", line 62, in <module>
eventDate += delta
File "/usr/lib/python2.7/dist-packages/dateutil/relativedelta.py", line 261, in __radd__
day = min(calendar.monthrange(year, month)[1],
AttributeError: 'module' object has no attribute 'monthrange'
Have I lost a module somewhere in the updates or has something in
python changed such that my code no longer works as it used to?
Can anyone help diagnose this please.