def rrule_to_text(rrule):
"""
Based on https://github.com/jkbrzt/rrule/
Convert an rrule data structure to human-readable text
"""
text = ['every', ]
if not hasattr(rrule, '_freq'):
raise Exception("Missing _freq")
if rrule._freq + 1 > len(FREQUENCY):
raise Exception("Can't do that frequency.")
text.append(FREQUENCY[rrule._freq](rrule))
if rrule._until:
text.extend([' ', _('until'), ' ', rrule._until.strftime(DATE_FORMAT)])
elif rrule._count:
text.extend([' ', _('for'), ' ', str(rrule._count), ])
text.extend([' ', gettext.ngettext('time', 'times', rrule._count)])
return ''.join(text)
评论列表
文章目录