Skip to content

Commit

Permalink
Made django.utils.timezone.localtime a private API -- it's too specif…
Browse files Browse the repository at this point in the history
…ic to the template engine.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17642 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
aaugustin committed Mar 3, 2012
1 parent c988397 commit 7ce1ad7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
9 changes: 7 additions & 2 deletions django/utils/timezone.py
Expand Up @@ -17,7 +17,7 @@
__all__ = [ __all__ = [
'utc', 'get_default_timezone', 'get_current_timezone', 'utc', 'get_default_timezone', 'get_current_timezone',
'activate', 'deactivate', 'override', 'activate', 'deactivate', 'override',
'localtime', 'is_naive', 'is_aware', 'make_aware', 'make_naive', 'is_naive', 'is_aware', 'make_aware', 'make_naive',
] ]




Expand Down Expand Up @@ -204,14 +204,16 @@ def __exit__(self, exc_type, exc_value, traceback):
del _active.value del _active.value




# Utilities # Templates


def localtime(value, use_tz=None): def localtime(value, use_tz=None):
""" """
Checks if value is a datetime and converts it to local time if necessary. Checks if value is a datetime and converts it to local time if necessary.
If use_tz is provided and is not None, that will force the value to If use_tz is provided and is not None, that will force the value to
be converted (or not), overriding the value of settings.USE_TZ. be converted (or not), overriding the value of settings.USE_TZ.
This function is designed for use by the template engine.
""" """
if (isinstance(value, datetime) if (isinstance(value, datetime)
and (settings.USE_TZ if use_tz is None else use_tz) and (settings.USE_TZ if use_tz is None else use_tz)
Expand All @@ -224,6 +226,9 @@ def localtime(value, use_tz=None):
value = timezone.normalize(value) value = timezone.normalize(value)
return value return value



# Utilities

def now(): def now():
""" """
Returns an aware or naive datetime.datetime, depending on settings.USE_TZ. Returns an aware or naive datetime.datetime, depending on settings.USE_TZ.
Expand Down
5 changes: 0 additions & 5 deletions docs/ref/utils.txt
Expand Up @@ -666,11 +666,6 @@ For a complete discussion on the usage of the following see the
``None``, the :ref:`current time zone <default-current-time-zone>` is unset ``None``, the :ref:`current time zone <default-current-time-zone>` is unset
on entry with :func:`deactivate()` instead. on entry with :func:`deactivate()` instead.


.. function:: localtime(value, use_tz=None)

This function is used by the template engine to convert datetimes to local
time where appropriate.

.. function:: now() .. function:: now()


Returns an aware or naive :class:`~datetime.datetime` that represents the Returns an aware or naive :class:`~datetime.datetime` that represents the
Expand Down

0 comments on commit 7ce1ad7

Please sign in to comment.