jinja2-time


Namejinja2-time JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/hackebrot/jinja2-time
SummaryJinja2 Extension for Dates and Times
upload_time2016-06-08 23:36:52
maintainerNone
docs_urlNone
authorRaphael Pierzina
requires_pythonNone
licenseMIT
keywords jinja2 extension time
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ===========
Jinja2 Time
===========

|pypi| |pyversions| |license| |travis-ci|

Jinja2 Extension for Dates and Times

.. |pypi| image:: https://img.shields.io/pypi/v/jinja2-time.svg
   :target: https://pypi.python.org/pypi/jinja2-time
   :alt: PyPI Package

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/jinja2-time.svg
   :target: https://pypi.python.org/pypi/jinja2-time/
   :alt: PyPI Python Versions

.. |license| image:: https://img.shields.io/pypi/l/jinja2-time.svg
   :target: https://pypi.python.org/pypi/jinja2-time
   :alt: PyPI Package License

.. |travis-ci| image:: https://travis-ci.org/hackebrot/jinja2-time.svg?branch=master
    :target: https://travis-ci.org/hackebrot/jinja2-time
    :alt: See Build Status on Travis CI

Installation
------------

**jinja2-time** is available for download from `PyPI`_ via `pip`_::

    $ pip install jinja2-time

It will automatically install `jinja2`_ along with `arrow`_.

.. _`jinja2`: https://github.com/mitsuhiko/jinja2
.. _`PyPI`: https://pypi.python.org/pypi
.. _`arrow`: https://github.com/crsmithdev/arrow
.. _`pip`: https://pypi.python.org/pypi/pip/

Usage
-----

Now Tag
~~~~~~~

The extension comes with a ``now`` tag that provides convenient access to the
`arrow.now()`_ API from your templates.

You can control the output by specifying a format, that will be passed to
Python's `strftime()`_:

.. _`arrow.now()`: http://crsmithdev.com/arrow/#arrow.factory.ArrowFactory.now
.. _`strftime()`: https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior

.. code-block:: python

    from jinja2 import Environment

    env = Environment(extensions=['jinja2_time.TimeExtension'])

    # Timezone 'local', default format -> "2015-12-10"
    template = env.from_string("{% now 'local' %}")

    # Timezone 'utc', explicit format -> "Thu, 10 Dec 2015 15:49:01"
    template = env.from_string("{% now 'utc', '%a, %d %b %Y %H:%M:%S' %}")

    # Timezone 'Europe/Berlin', explicit format -> "CET +0100"
    template = env.from_string("{% now 'Europe/Berlin', '%Z %z' %}")

    # Timezone 'utc', explicit format -> "2015"
    template = env.from_string("{% now 'utc', '%Y' %}")

    template.render()

Default Datetime Format
~~~~~~~~~~~~~~~~~~~~~~~

**TimeExtension** extends the environment with a ``datetime_format`` attribute.

It is used as a fallback if you omit the format for ``now``.

.. code-block:: python

    from jinja2 import Environment

    env = Environment(extensions=['jinja2_time.TimeExtension'])

    env.datetime_format = '%a, %d %b %Y %H:%M:%S'

    # Timezone 'utc', default format -> "Thu, 10 Dec 2015 15:49:01"
    template = env.from_string("{% now 'utc' %}")

    template.render()

Time Offset
~~~~~~~~~~~

**jinja2-time** implements a convenient interface to modify ``now`` by a
relative time offset:

.. code-block:: python

    # Examples for now "2015-12-09 23:33:01"

    # "Thu, 10 Dec 2015 01:33:31"
    "{% now 'utc' + 'hours=2, seconds=30' %}"

    # "Wed, 09 Dec 2015 23:22:01"
    "{% now 'utc' - 'minutes=11' %}"

    # "07 Dec 2015 23:00:00"
    "{% now 'utc' - 'days=2, minutes=33, seconds=1', '%d %b %Y %H:%M:%S' %}"

Further documentation on the underlying functionality can be found in the
`arrow replace docs`_.

.. _`arrow replace docs`: http://arrow.readthedocs.io/en/latest/#replace-shift


Issues
------

If you encounter any problems, please `file an issue`_ along with a detailed description.

.. _`file an issue`: https://github.com/hackebrot/jinja2-time/issues


Code of Conduct
---------------

Everyone interacting in the jinja2-time project's codebases, issue trackers, chat
rooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.

.. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/

License
-------

Distributed under the terms of the `MIT`_ license, jinja2-time is free and open source software

.. image:: https://opensource.org/trademarks/osi-certified/web/osi-certified-120x100.png
   :align: left
   :alt: OSI certified
   :target: https://opensource.org/

.. _`MIT`: http://opensource.org/licenses/MIT
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/hackebrot/jinja2-time",
    "name": "jinja2-time",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "jinja2,extension,time",
    "author": "Raphael Pierzina",
    "author_email": "raphael@hackebrot.de",
    "download_url": "https://files.pythonhosted.org/packages/de/7c/ee2f2014a2a0616ad3328e58e7dac879251babdb4cb796d770b5d32c469f/jinja2-time-0.2.0.tar.gz",
    "platform": "UNKNOWN",
    "description": "===========\nJinja2 Time\n===========\n\n|pypi| |pyversions| |license| |travis-ci|\n\nJinja2 Extension for Dates and Times\n\n.. |pypi| image:: https://img.shields.io/pypi/v/jinja2-time.svg\n   :target: https://pypi.python.org/pypi/jinja2-time\n   :alt: PyPI Package\n\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/jinja2-time.svg\n   :target: https://pypi.python.org/pypi/jinja2-time/\n   :alt: PyPI Python Versions\n\n.. |license| image:: https://img.shields.io/pypi/l/jinja2-time.svg\n   :target: https://pypi.python.org/pypi/jinja2-time\n   :alt: PyPI Package License\n\n.. |travis-ci| image:: https://travis-ci.org/hackebrot/jinja2-time.svg?branch=master\n    :target: https://travis-ci.org/hackebrot/jinja2-time\n    :alt: See Build Status on Travis CI\n\nInstallation\n------------\n\n**jinja2-time** is available for download from `PyPI`_ via `pip`_::\n\n    $ pip install jinja2-time\n\nIt will automatically install `jinja2`_ along with `arrow`_.\n\n.. _`jinja2`: https://github.com/mitsuhiko/jinja2\n.. _`PyPI`: https://pypi.python.org/pypi\n.. _`arrow`: https://github.com/crsmithdev/arrow\n.. _`pip`: https://pypi.python.org/pypi/pip/\n\nUsage\n-----\n\nNow Tag\n~~~~~~~\n\nThe extension comes with a ``now`` tag that provides convenient access to the\n`arrow.now()`_ API from your templates.\n\nYou can control the output by specifying a format, that will be passed to\nPython's `strftime()`_:\n\n.. _`arrow.now()`: http://crsmithdev.com/arrow/#arrow.factory.ArrowFactory.now\n.. _`strftime()`: https://docs.python.org/3.5/library/datetime.html#strftime-and-strptime-behavior\n\n.. code-block:: python\n\n    from jinja2 import Environment\n\n    env = Environment(extensions=['jinja2_time.TimeExtension'])\n\n    # Timezone 'local', default format -> \"2015-12-10\"\n    template = env.from_string(\"{% now 'local' %}\")\n\n    # Timezone 'utc', explicit format -> \"Thu, 10 Dec 2015 15:49:01\"\n    template = env.from_string(\"{% now 'utc', '%a, %d %b %Y %H:%M:%S' %}\")\n\n    # Timezone 'Europe/Berlin', explicit format -> \"CET +0100\"\n    template = env.from_string(\"{% now 'Europe/Berlin', '%Z %z' %}\")\n\n    # Timezone 'utc', explicit format -> \"2015\"\n    template = env.from_string(\"{% now 'utc', '%Y' %}\")\n\n    template.render()\n\nDefault Datetime Format\n~~~~~~~~~~~~~~~~~~~~~~~\n\n**TimeExtension** extends the environment with a ``datetime_format`` attribute.\n\nIt is used as a fallback if you omit the format for ``now``.\n\n.. code-block:: python\n\n    from jinja2 import Environment\n\n    env = Environment(extensions=['jinja2_time.TimeExtension'])\n\n    env.datetime_format = '%a, %d %b %Y %H:%M:%S'\n\n    # Timezone 'utc', default format -> \"Thu, 10 Dec 2015 15:49:01\"\n    template = env.from_string(\"{% now 'utc' %}\")\n\n    template.render()\n\nTime Offset\n~~~~~~~~~~~\n\n**jinja2-time** implements a convenient interface to modify ``now`` by a\nrelative time offset:\n\n.. code-block:: python\n\n    # Examples for now \"2015-12-09 23:33:01\"\n\n    # \"Thu, 10 Dec 2015 01:33:31\"\n    \"{% now 'utc' + 'hours=2, seconds=30' %}\"\n\n    # \"Wed, 09 Dec 2015 23:22:01\"\n    \"{% now 'utc' - 'minutes=11' %}\"\n\n    # \"07 Dec 2015 23:00:00\"\n    \"{% now 'utc' - 'days=2, minutes=33, seconds=1', '%d %b %Y %H:%M:%S' %}\"\n\nFurther documentation on the underlying functionality can be found in the\n`arrow replace docs`_.\n\n.. _`arrow replace docs`: http://arrow.readthedocs.io/en/latest/#replace-shift\n\n\nIssues\n------\n\nIf you encounter any problems, please `file an issue`_ along with a detailed description.\n\n.. _`file an issue`: https://github.com/hackebrot/jinja2-time/issues\n\n\nCode of Conduct\n---------------\n\nEveryone interacting in the jinja2-time project's codebases, issue trackers, chat\nrooms, and mailing lists is expected to follow the `PyPA Code of Conduct`_.\n\n.. _`PyPA Code of Conduct`: https://www.pypa.io/en/latest/code-of-conduct/\n\nLicense\n-------\n\nDistributed under the terms of the `MIT`_ license, jinja2-time is free and open source software\n\n.. image:: https://opensource.org/trademarks/osi-certified/web/osi-certified-120x100.png\n   :align: left\n   :alt: OSI certified\n   :target: https://opensource.org/\n\n.. _`MIT`: http://opensource.org/licenses/MIT",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Jinja2 Extension for Dates and Times",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/hackebrot/jinja2-time"
    },
    "split_keywords": [
        "jinja2",
        "extension",
        "time"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6aa1d44fa38306ffa34a7e1af09632b158e13ec89670ce491f8a15af3ebcb4e4",
                "md5": "d0d553ae5c3e9e7abb79c044acd165c8",
                "sha256": "d3eab6605e3ec8b7a0863df09cc1d23714908fa61aa6986a845c20ba488b4efa"
            },
            "downloads": -1,
            "filename": "jinja2_time-0.2.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d0d553ae5c3e9e7abb79c044acd165c8",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 6360,
            "upload_time": "2016-06-08T23:36:48",
            "upload_time_iso_8601": "2016-06-08T23:36:48.197942Z",
            "url": "https://files.pythonhosted.org/packages/6a/a1/d44fa38306ffa34a7e1af09632b158e13ec89670ce491f8a15af3ebcb4e4/jinja2_time-0.2.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "de7cee2f2014a2a0616ad3328e58e7dac879251babdb4cb796d770b5d32c469f",
                "md5": "b6ebc4ecac395a18982532f4c2869c06",
                "sha256": "d14eaa4d315e7688daa4969f616f226614350c48730bfa1692d2caebd8c90d40"
            },
            "downloads": -1,
            "filename": "jinja2-time-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "b6ebc4ecac395a18982532f4c2869c06",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 5701,
            "upload_time": "2016-06-08T23:36:52",
            "upload_time_iso_8601": "2016-06-08T23:36:52.454491Z",
            "url": "https://files.pythonhosted.org/packages/de/7c/ee2f2014a2a0616ad3328e58e7dac879251babdb4cb796d770b5d32c469f/jinja2-time-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2016-06-08 23:36:52",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "hackebrot",
    "github_project": "jinja2-time",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "jinja2-time"
}
        
Elapsed time: 0.42148s