コード例 #1
0
ファイル: webapp_extras.py プロジェクト: paulcwatts/1hph
def mytimesince(value, arg=None):
    """Formats a date as the time since that date (i.e. "4 days, 6 hours")."""
    from gonzo.webapp.templatetags.timesince import mytimesince
    if not value:
        return u''
    try:
        if arg:
            return mytimesince(value, arg)
        return mytimesince(value)
    except (ValueError, TypeError):
        return u''
コード例 #2
0
ファイル: webapp_extras.py プロジェクト: paulcwatts/1hph
def hunt_status(hunt):
    from gonzo.webapp.templatetags.timesince import mytimesince, mytimeuntil
    state = hunt.get_state()
    if state == Hunt.State.FUTURE:
        return "Hunt begins in " + mytimeuntil(hunt.start_time)
    elif state == Hunt.State.CURRENT:
        return "Hunt ends in " + mytimeuntil(hunt.end_time)
    elif state == Hunt.State.VOTING:
        return "Voting ends in " + mytimeuntil(hunt.vote_end_time)
    elif state == Hunt.State.FINISHED:
        return "Hunt ended %s ago" % (mytimesince(hunt.vote_end_time),)