Giter Club home page Giter Club logo

jinja2_humanize_extension's Issues

Broken dependency on `humanize.abs_timedelta`

As of v4.0.0 of humanize, abs_timedelta() is deprecated.

My installation (humanize-4.0.0, jinja2-3.0.3, jinja2-humanize-extension-0.2.0) produces this:

Traceback (most recent call last):
  File "/var/tmp/pbench-test-server/test-2/opt/pbench-server/bin/pbench-tarball-stats.py", line 325, in <module>
    status = main(parsed)
  File "/var/tmp/pbench-test-server/test-2/opt/pbench-server/bin/pbench-tarball-stats.py", line 297, in main
    env = jinja2.Environment(
  File "/var/tmp/tox/jenkins-unittests/lib/python3.9/site-packages/jinja2/environment.py", line 362, in __init__
    self.extensions = load_extensions(self, extensions)
  File "/var/tmp/tox/jenkins-unittests/lib/python3.9/site-packages/jinja2/environment.py", line 118, in load_extensions
    extension = t.cast(t.Type["Extension"], import_string(extension))
  File "/var/tmp/tox/jenkins-unittests/lib/python3.9/site-packages/jinja2/utils.py", line 215, in import_string
    return getattr(__import__(module, None, None, [obj]), obj)
  File "/var/tmp/tox/jenkins-unittests/lib/python3.9/site-packages/jinja2_humanize_extension/__init__.py", line 5, in <module>
    from humanize.time import (
ImportError: cannot import name 'abs_timedelta' from 'humanize.time' (/var/tmp/tox/jenkins-unittests/lib/python3.9/site-packages/humanize/time.py)

Use more recent version of humanize?

jinja2 humanize does not work with values that are timezone aware. In order to get the right result, one must do stuff like:

{{ t.astimezone().replace(tzinfo=None) | humanize_naturaltime }}

or

{{ t | humanize_naturaltime(when=datetime.datetime.now(tz=dateutil.tz.gettz()) ) }}

More recent versions of humanize work well with time/datetime/date objects with timezone set, and that would allow the following to work:

{{ t | humanize_naturaltime }}

Are there any specific reasons why the requirements.txt file is set to not use above version 3 of humanize?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.