metomi / isodatetime

:date: :watch: Python ISO 8601 date time parser and data model/manipulation utilities
GNU Lesser General Public License v3.0
37 stars 20 forks source link

Cannot add Duration to or set time zone of truncated TimePoint #168

Open MetRonnie opened 4 years ago

MetRonnie commented 4 years ago

Possibly related to #80

>>> A = TimePoint(day_of_month=30, hour_of_day=9)
---30T09Z
>>> A + Duration(hours=2)
metomi/isodatetime/data.py in __add__(self, other, no_copy)
   1323         if duration.hours:
   1324             new.hour_of_day += duration.hours
-> 1325             new.tick_over()
   1326         if duration.days:
   1327             if new.get_is_calendar_date():

metomi/isodatetime/data.py in tick_over(self, check_changes)
   1651             self.day_of_week = days + 1
   1652         if self.day_of_month is not None:
-> 1653             self._tick_over_day_of_month()
   1654         if self.day_of_year is not None:
   1655             while self.day_of_year < 1:

metomi/isodatetime/data.py in _tick_over_day_of_month(self)
   1711                 self.day_of_month = day
   1712         else:
-> 1713             month_index = (self.month_of_year - 1) % CALENDAR.MONTHS_IN_YEAR
   1714             if get_is_leap_year(self.year):
   1715                 max_day_in_month = CALENDAR.DAYS_IN_MONTHS_LEAP[month_index]

TypeError: unsupported operand type(s) for -: 'NoneType' and 'int'

This bug also means I get the same error for A.set_time_zone()

Tested @ 4bbc372