All Projects → hackebrot → jinja2-time

hackebrot / jinja2-time

Licence: MIT license
📆 Jinja2 Extension for Dates and Times

Programming Languages

python
139335 projects - #7 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to jinja2-time

qrono
🕥 Just right date time library
Stars: ✭ 111 (+73.44%)
Mutual labels:  time
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-70.31%)
Mutual labels:  time
relative.time.parser
Moment.js Plugin for parsing Relative Time Strings
Stars: ✭ 13 (-79.69%)
Mutual labels:  time
rutimeparser
Recognize date and time in russian text and return datetime.datetime.
Stars: ✭ 17 (-73.44%)
Mutual labels:  time
hs-hourglass
efficient and simpler time API for haskell
Stars: ✭ 43 (-32.81%)
Mutual labels:  time
shamsi date
A Flutter and Dart package for using Jalali (Shamsi, Solar, Persian or Jalaali) calendar. You can convert, format and manipulate Jalali and Gregorian (Miladi) date and times.
Stars: ✭ 59 (-7.81%)
Mutual labels:  time
ElevenClock
ElevenClock: Customize Windows 11 taskbar clock
Stars: ✭ 1,494 (+2234.38%)
Mutual labels:  time
about-time
A cool helper for tracking time and throughput of code blocks, with beautiful human friendly renditions.
Stars: ✭ 36 (-43.75%)
Mutual labels:  time
duration-humanizer
361000 becomes "6 minutes, 1 second"
Stars: ✭ 61 (-4.69%)
Mutual labels:  time
timeskew
Override time reporting in Linux processes (accelerate/slowdown games, test code involving timers/delays)
Stars: ✭ 36 (-43.75%)
Mutual labels:  time
go-systemd-time
📅 Go implementation of systemd relative time adjustments
Stars: ✭ 21 (-67.19%)
Mutual labels:  time
time-aware-template
Time Aware is a configurable application template that enables you to display time enabled layers in an ArcGIS web map using a time slider.
Stars: ✭ 20 (-68.75%)
Mutual labels:  time
pest-plugin-test-time
A Pest plugin to control the flow of time
Stars: ✭ 31 (-51.56%)
Mutual labels:  time
roundup
un-official mirror of http://hg.code.sf.net/p/roundup/code -- used for CI. Please visit https://issues.roundup-tracker.org for finding starter issues or log new issues.
Stars: ✭ 20 (-68.75%)
Mutual labels:  jinja2
Flask-QRcode
A concise Flask extension to easily render QR codes on Jinja2 templates using python-qrcode.
Stars: ✭ 89 (+39.06%)
Mutual labels:  jinja2
faketime
Fake currentTimeMillis() without class loader hacks
Stars: ✭ 100 (+56.25%)
Mutual labels:  time
dt
Go's missing DateTime package
Stars: ✭ 34 (-46.87%)
Mutual labels:  time
popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (-59.37%)
Mutual labels:  time
web-7.0
The freenode website, home to our blog, knowledge base and policies
Stars: ✭ 112 (+75%)
Mutual labels:  jinja2
pipen
pipen - A pipeline framework for python
Stars: ✭ 82 (+28.13%)
Mutual labels:  jinja2

Jinja2 Time

PyPI Package PyPI Python Versions PyPI Package License See Build Status on Travis CI

Jinja2 Extension for Dates and Times

Installation

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

$ pip install jinja2-time

It will automatically install jinja2 along with arrow.

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():

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.

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:

# 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.

Issues

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

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.

License

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

OSI certified
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].