provide a naive UNTIL= datestamp for schedules for UI convenience

This commit is contained in:
Ryan Petrello
2018-05-09 15:11:02 -04:00
parent 056933e33e
commit c52eb0f327
3 changed files with 85 additions and 1 deletions

View File

@@ -122,6 +122,17 @@ class Schedule(CommonModel, LaunchTimeConfig):
logger.warn('Could not detect valid zoneinfo for {}'.format(self.rrule))
return ''
@property
def until(self):
# The UNTIL= datestamp (if any) coerced from UTC to the local naive time
# of the DTSTART
for r in Schedule.rrulestr(self.rrule)._rrule:
if r._until:
local_until = r._until.astimezone(r._dtstart.tzinfo)
naive_until = local_until.replace(tzinfo=None)
return naive_until.isoformat()
return ''
@classmethod
def coerce_naive_until(cls, rrule):
#