utils.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:django-happenings 作者: natgeosociety 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号