Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions SpiffWorkflow/bpmn/specs/event_definitions/timer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,14 @@ def get_timedelta_from_start(parsed_duration, start=None):
months += years * 12

for idx in range(int(months)):
year, month = start.year + idx // 12, start.month + idx % 12
year = start.year + (start.month + idx - 1) // 12
month = (start.month + idx) % 12 or 12
days += monthrange(year, month)[1]

year, month = start.year + months // 12, start.month + months % 12
year = start.year + (start.month + months - 1) // 12
month = (start.month + months) % 12 or 12
days += (months - int(months)) * monthrange(year, month)[1]

parsed_duration['days'] = days
return timedelta(**parsed_duration)

Expand All @@ -53,12 +56,13 @@ def get_timedelta_from_end(parsed_duration, end):

for idx in range(1, int(months) + 1):
year = end.year - (1 + (idx - end.month) // 12)
month = 1 + (end.month - idx - 1) % 12
month = (end.month - idx) % 12 or 12
days += monthrange(year, month)[1]

days += (months - int(months)) * monthrange(
end.year - (1 + (int(months)- end.month) // 12),
1 + (end.month - months - 1) % 12)[1]
year = end.year - (1 + (months - end.month) // 12)
month = (end.month - months) % 12 or 12
days += (months - int(months)) * monthrange(year, month)[1]

parsed_duration['days'] = days
return timedelta(**parsed_duration)

Expand Down Expand Up @@ -200,4 +204,4 @@ def details(self, my_task):
event_value = my_task._get_internal_data('event_value')
if event_value is not None and event_value['cycles'] != 0:
event_value = event_value['next']
return PendingBpmnEvent(self.name, self.__class__.__name__, event_value)
return PendingBpmnEvent(self.name, self.__class__.__name__, event_value)