How to use the humanize.time._now function in humanize

To help you get started, we’ve selected a few humanize 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 vitalk / flask-humanize / tests / test_humanize.py View on Github external
def test_use_utc(self, h):
        assert humanize.time._now == datetime.utcnow
github vitalk / flask-humanize / flask_humanize / __init__.py View on Github external
humanize.init_app(app)

        """
        for k, v in default_config.items():
            app.config.setdefault(self_name(k), v)

        if app_has_babel(app):
            default_locale = app.config['BABEL_DEFAULT_LOCALE']
            if default_locale is not None:
                app.config.setdefault(self_name('default_locale'), default_locale)

        if app.config.get('HUMANIZE_USE_UTC'):
            # Override humanize.time._now to use UTC time
            humanize.time._now = datetime.utcnow
        else:
            humanize.time._now = datetime.now

        app.add_template_filter(self._humanize, 'humanize')
        app.before_request(self._set_locale)
        app.after_request(self._unset_locale)

        if not hasattr(app, 'extensions'):
            app.extensions = {}
        app.extensions['humanize'] = self
github vitalk / flask-humanize / flask_humanize / __init__.py View on Github external
app = create_app()
            humanize.init_app(app)

        """
        for k, v in default_config.items():
            app.config.setdefault(self_name(k), v)

        if app_has_babel(app):
            default_locale = app.config['BABEL_DEFAULT_LOCALE']
            if default_locale is not None:
                app.config.setdefault(self_name('default_locale'), default_locale)

        if app.config.get('HUMANIZE_USE_UTC'):
            # Override humanize.time._now to use UTC time
            humanize.time._now = datetime.utcnow
        else:
            humanize.time._now = datetime.now

        app.add_template_filter(self._humanize, 'humanize')
        app.before_request(self._set_locale)
        app.after_request(self._unset_locale)

        if not hasattr(app, 'extensions'):
            app.extensions = {}
        app.extensions['humanize'] = self