mirror of
https://github.com/django/django.git
synced 2025-08-03 18:38:50 +00:00
Fixed #25181 -- Added localdate() function to get date in a different time zone.
Thanks Konrad Świat for the original patch.
This commit is contained in:
parent
d8ef5b0e65
commit
ff1e7b4eb4
4 changed files with 65 additions and 5 deletions
|
@ -974,14 +974,32 @@ appropriate entities.
|
|||
|
||||
``override`` is also usable as a function decorator.
|
||||
|
||||
.. function:: localtime(value, timezone=None)
|
||||
.. function:: localtime(value=None, timezone=None)
|
||||
|
||||
Converts an aware :class:`~datetime.datetime` to a different time zone,
|
||||
by default the :ref:`current time zone <default-current-time-zone>`.
|
||||
|
||||
When ``value`` is omitted, it defaults to :func:`now`.
|
||||
|
||||
This function doesn't work on naive datetimes; use :func:`make_aware`
|
||||
instead.
|
||||
|
||||
.. versionchanged:: 1.11
|
||||
|
||||
In older versions, ``value`` is a required argument.
|
||||
|
||||
.. function:: localdate(value=None, timezone=None)
|
||||
|
||||
.. versionadded:: 1.11
|
||||
|
||||
Uses :func:`localtime` to convert an aware :class:`~datetime.datetime` to a
|
||||
:meth:`~datetime.datetime.date` in a different time zone, by default the
|
||||
:ref:`current time zone <default-current-time-zone>`.
|
||||
|
||||
When ``value`` is omitted, it defaults to :func:`now`.
|
||||
|
||||
This function doesn't work on naive datetimes.
|
||||
|
||||
.. function:: now()
|
||||
|
||||
Returns a :class:`~datetime.datetime` that represents the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue