diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-05-02 14:02:39 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2015-05-02 21:11:03 +0200 |
| commit | 432678dbc1dd4f80203468d83bb0eb6c20ed5247 (patch) | |
| tree | 499c83769c31205544a98925243fa522daf0aa06 /django/utils/timezone.py | |
| parent | b0bd1f0e19857ed8c085f4621c5b7fcfde5ec040 (diff) | |
Simplified the implementation of timezone.is_aware/naive.
Diffstat (limited to 'django/utils/timezone.py')
| -rw-r--r-- | django/utils/timezone.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/django/utils/timezone.py b/django/utils/timezone.py index 04108f658f..70fd5e3e48 100644 --- a/django/utils/timezone.py +++ b/django/utils/timezone.py @@ -331,20 +331,26 @@ def is_aware(value): """ Determines if a given datetime.datetime is aware. - The logic is described in Python's docs: + The concept is defined in Python's docs: http://docs.python.org/library/datetime.html#datetime.tzinfo + + Assuming value.tzinfo is either None or a proper datetime.tzinfo, + value.utcoffset() implements the appropriate logic. """ - return value.tzinfo is not None and value.tzinfo.utcoffset(value) is not None + return value.utcoffset() is not None def is_naive(value): """ Determines if a given datetime.datetime is naive. - The logic is described in Python's docs: + The concept is defined in Python's docs: http://docs.python.org/library/datetime.html#datetime.tzinfo + + Assuming value.tzinfo is either None or a proper datetime.tzinfo, + value.utcoffset() implements the appropriate logic. """ - return value.tzinfo is None or value.tzinfo.utcoffset(value) is None + return value.utcoffset() is None def make_aware(value, timezone=None, is_dst=None): |
