module documentation

Undocumented

Variable register Undocumented
Class datetimeobject Undocumented
Class ​Get​Current​Timezone​Node Template node class used by get_current_timezone_tag.
Class ​Local​Time​Node Template node class used by localtime_tag.
Class ​Timezone​Node Template node class used by timezone_tag.
Class ​Unknown​Timezone​Exception Undocumented
Function do​_timezone Convert a datetime to local time in a given time zone.
Function get​_current​_timezone​_tag Store the name of the current time zone in the context.
Function localtime Convert a datetime to local time in the active time zone.
Function localtime​_tag Force or prevent conversion of datetime objects to local time, regardless of the value of settings.USE_TZ.
Function timezone​_constructor Undocumented
Function timezone​_tag Enable a given time zone just for this block.
Function utc Convert a datetime to UTC.
register =

Undocumented

@register.filter('timezone')
def do_timezone(value, arg):

Convert a datetime to local time in a given time zone.

The argument must be an instance of a tzinfo subclass or a time zone name.

Naive datetimes are assumed to be in local time in the default time zone.

@register.tag('get_current_timezone')
def get_current_timezone_tag(parser, token):

Store the name of the current time zone in the context.

Usage:

{% get_current_timezone as TIME_ZONE %}

This will fetch the currently active time zone and put its name into the TIME_ZONE context variable.

@register.filter
def localtime(value):

Convert a datetime to local time in the active time zone.

This only makes sense within a {% localtime off %} block.

@register.tag('localtime')
def localtime_tag(parser, token):

Force or prevent conversion of datetime objects to local time, regardless of the value of settings.USE_TZ.

Sample usage:

{% localtime off %}{{ value_in_utc }}{% endlocaltime %}
def timezone_constructor(tzname):

Undocumented

@register.tag('timezone')
def timezone_tag(parser, token):

Enable a given time zone just for this block.

The timezone argument must be an instance of a tzinfo subclass, a time zone name, or None. If it is None, the default time zone is used within the block.

Sample usage:

{% timezone "Europe/Paris" %}
    It is {{ now }} in Paris.
{% endtimezone %}
@register.filter
def utc(value):
Convert a datetime to UTC.