How to use the timeago.locales.timeago_template function in timeago

To help you get started, we’ve selected a few timeago examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hustcc / timeago / src / timeago / __init__.py View on Github external
tmp = SEC_ARRAY[i]
        if diff_seconds >= tmp:
            i += 1
            diff_seconds /= tmp
        else:
            break
    diff_seconds = int(diff_seconds)
    i *= 2

    if diff_seconds > (i == 0 and 9 or 1):
        i += 1

    if locale is None:
        locale = DEFAULT_LOCALE

    tmp = timeago_template(locale, i, ago_in)
    if hasattr(tmp, '__call__'):
        tmp = tmp(diff_seconds)
    return '%s' in tmp and tmp % diff_seconds or tmp

timeago

A very simple python library, used to format datetime with `*** time ago` statement. eg: "3 hours ago".

MIT
Latest version published 2 years ago

Package Health Score

58 / 100
Full package analysis