Skip to content

Commit

Permalink
first set of merge and extend
Browse files Browse the repository at this point in the history
  • Loading branch information
RomainMapado committed Oct 24, 2016
1 parent e3c171f commit f085aa2
Show file tree
Hide file tree
Showing 3 changed files with 901 additions and 0 deletions.
27 changes: 27 additions & 0 deletions datection/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,33 @@ def set_weekdays(self, weekdays):
self.duration_rrule['rrule'])
self.rrule._byweekday = [w.weekday for w in weekdays]

def set_startdate(self, start_date):
"""
Update the rrule start date property and the underlying dstart.
"""
self.duration_rrule['rrule'] = re.sub(
r'(?<=DTSTART:)[^\n]+',
start_date.strftime('%Y%m%d'),
self.duration_rrule['rrule'])
self.rrule.dstart = start_date

def set_enddate(self, end_date):
"""
Update the rrule end date property and the underlying _until.
"""
if end_date is not None:
self.duration_rrule['rrule'] = re.sub(
r'(?<=UNTIL=)[^T]+',
end_date.strftime('%Y%m%d'),
self.duration_rrule['rrule'])
else:
self.duration_rrule['rrule'] = re.sub(
r'(?<=UNTIL=)[^T]+',
'',
self.duration_rrule['rrule'])

self.rrule._until = end_date

@cached_property
def exclusion_rrules(self):
"""Return the list of exclusion rrules."""
Expand Down
Loading

0 comments on commit f085aa2

Please sign in to comment.