Loading django/contrib/humanize/tests.py +3 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ from django.template import Template, Context, defaultfilters from django.test import TestCase from django.test.utils import override_settings from django.utils.html import escape from django.utils.timezone import utc from django.utils.timezone import utc, get_fixed_timezone from django.utils import translation from django.utils.translation import ugettext as _ from django.utils import tzinfo from i18n import TransRealMixin Loading Loading @@ -153,8 +152,8 @@ class HumanizeTests(TransRealMixin, TestCase): def test_naturalday_tz(self): today = datetime.date.today() tz_one = tzinfo.FixedOffset(datetime.timedelta(hours=-12)) tz_two = tzinfo.FixedOffset(datetime.timedelta(hours=12)) tz_one = get_fixed_timezone(-720) tz_two = get_fixed_timezone(720) # Can be today or yesterday date_one = datetime.datetime(today.year, today.month, today.day, tzinfo=tz_one) Loading django/contrib/syndication/views.py +6 −6 Original line number Diff line number Diff line Loading @@ -7,12 +7,12 @@ from django.contrib.sites.models import get_current_site from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.http import HttpResponse, Http404 from django.template import loader, TemplateDoesNotExist, RequestContext from django.utils import feedgenerator, tzinfo from django.utils import feedgenerator from django.utils.encoding import force_text, iri_to_uri, smart_text from django.utils.html import escape from django.utils.http import http_date from django.utils import six from django.utils.timezone import is_naive from django.utils.timezone import get_default_timezone, is_naive, make_aware def add_domain(domain, url, secure=False): Loading Loading @@ -186,15 +186,15 @@ class Feed(object): else: author_email = author_link = None tz = get_default_timezone() pubdate = self.__get_dynamic_attr('item_pubdate', item) if pubdate and is_naive(pubdate): ltz = tzinfo.LocalTimezone(pubdate) pubdate = pubdate.replace(tzinfo=ltz) pubdate = make_aware(pubdate, tz) updateddate = self.__get_dynamic_attr('item_updateddate', item) if updateddate and is_naive(updateddate): ltz = tzinfo.LocalTimezone(updateddate) updateddate = updateddate.replace(tzinfo=ltz) updateddate = make_aware(updateddate, tz) feed.add_item( title = title, Loading django/utils/dateformat.py +2 −3 Original line number Diff line number Diff line Loading @@ -18,11 +18,10 @@ import calendar import datetime from django.utils.dates import MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR from django.utils.tzinfo import LocalTimezone from django.utils.translation import ugettext as _ from django.utils.encoding import force_text from django.utils import six from django.utils.timezone import is_aware, is_naive from django.utils.timezone import get_default_timezone, is_aware, is_naive re_formatchars = re.compile(r'(?<!\\)([aAbBcdDeEfFgGhHiIjlLmMnNoOPrsStTUuwWyYzZ])') re_escaped = re.compile(r'\\(.)') Loading @@ -48,7 +47,7 @@ class TimeFormat(Formatter): # or time objects (against established django policy). if isinstance(obj, datetime.datetime): if is_naive(obj): self.timezone = LocalTimezone(obj) self.timezone = get_default_timezone() else: self.timezone = obj.tzinfo Loading django/utils/dateparse.py +5 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,8 @@ import datetime import re from django.utils import six from django.utils.timezone import utc from django.utils.tzinfo import FixedOffset from django.utils.timezone import utc, get_fixed_timezone date_re = re.compile( r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$' Loading @@ -27,6 +27,7 @@ datetime_re = re.compile( r'(?P<tzinfo>Z|[+-]\d{2}:?\d{2})?$' ) def parse_date(value): """Parses a string and return a datetime.date. Loading Loading @@ -59,7 +60,7 @@ def parse_datetime(value): """Parses a string and return a datetime.datetime. This function supports time zone offsets. When the input contains one, the output uses an instance of FixedOffset as tzinfo. the output uses a timezone with a fixed offset from UTC. Raises ValueError if the input is well formatted but not a valid datetime. Returns None if the input isn't well formatted. Loading @@ -76,7 +77,7 @@ def parse_datetime(value): offset = 60 * int(tzinfo[1:3]) + int(tzinfo[-2:]) if tzinfo[0] == '-': offset = -offset tzinfo = FixedOffset(offset) tzinfo = get_fixed_timezone(offset) kw = dict((k, int(v)) for k, v in six.iteritems(kw) if v is not None) kw['tzinfo'] = tzinfo return datetime.datetime(**kw) tests/model_regress/tests.py +3 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ import unittest from django.core.exceptions import ValidationError from django.test import TestCase, skipUnlessDBFeature from django.utils import six from django.utils import tzinfo from django.utils.timezone import get_fixed_timezone from django.db import connection, router from django.db.models.sql import InsertQuery Loading Loading @@ -189,8 +189,8 @@ class ModelTests(TestCase): # Regression test for #10443. # The idea is that all these creations and saving should work without # crashing. It's not rocket science. dt1 = datetime.datetime(2008, 8, 31, 16, 20, tzinfo=tzinfo.FixedOffset(600)) dt2 = datetime.datetime(2008, 8, 31, 17, 20, tzinfo=tzinfo.FixedOffset(600)) dt1 = datetime.datetime(2008, 8, 31, 16, 20, tzinfo=get_fixed_timezone(600)) dt2 = datetime.datetime(2008, 8, 31, 17, 20, tzinfo=get_fixed_timezone(600)) obj = Article.objects.create( headline="A headline", pub_date=dt1, article_text="foo" ) Loading Loading
django/contrib/humanize/tests.py +3 −4 Original line number Diff line number Diff line Loading @@ -14,10 +14,9 @@ from django.template import Template, Context, defaultfilters from django.test import TestCase from django.test.utils import override_settings from django.utils.html import escape from django.utils.timezone import utc from django.utils.timezone import utc, get_fixed_timezone from django.utils import translation from django.utils.translation import ugettext as _ from django.utils import tzinfo from i18n import TransRealMixin Loading Loading @@ -153,8 +152,8 @@ class HumanizeTests(TransRealMixin, TestCase): def test_naturalday_tz(self): today = datetime.date.today() tz_one = tzinfo.FixedOffset(datetime.timedelta(hours=-12)) tz_two = tzinfo.FixedOffset(datetime.timedelta(hours=12)) tz_one = get_fixed_timezone(-720) tz_two = get_fixed_timezone(720) # Can be today or yesterday date_one = datetime.datetime(today.year, today.month, today.day, tzinfo=tz_one) Loading
django/contrib/syndication/views.py +6 −6 Original line number Diff line number Diff line Loading @@ -7,12 +7,12 @@ from django.contrib.sites.models import get_current_site from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist from django.http import HttpResponse, Http404 from django.template import loader, TemplateDoesNotExist, RequestContext from django.utils import feedgenerator, tzinfo from django.utils import feedgenerator from django.utils.encoding import force_text, iri_to_uri, smart_text from django.utils.html import escape from django.utils.http import http_date from django.utils import six from django.utils.timezone import is_naive from django.utils.timezone import get_default_timezone, is_naive, make_aware def add_domain(domain, url, secure=False): Loading Loading @@ -186,15 +186,15 @@ class Feed(object): else: author_email = author_link = None tz = get_default_timezone() pubdate = self.__get_dynamic_attr('item_pubdate', item) if pubdate and is_naive(pubdate): ltz = tzinfo.LocalTimezone(pubdate) pubdate = pubdate.replace(tzinfo=ltz) pubdate = make_aware(pubdate, tz) updateddate = self.__get_dynamic_attr('item_updateddate', item) if updateddate and is_naive(updateddate): ltz = tzinfo.LocalTimezone(updateddate) updateddate = updateddate.replace(tzinfo=ltz) updateddate = make_aware(updateddate, tz) feed.add_item( title = title, Loading
django/utils/dateformat.py +2 −3 Original line number Diff line number Diff line Loading @@ -18,11 +18,10 @@ import calendar import datetime from django.utils.dates import MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR from django.utils.tzinfo import LocalTimezone from django.utils.translation import ugettext as _ from django.utils.encoding import force_text from django.utils import six from django.utils.timezone import is_aware, is_naive from django.utils.timezone import get_default_timezone, is_aware, is_naive re_formatchars = re.compile(r'(?<!\\)([aAbBcdDeEfFgGhHiIjlLmMnNoOPrsStTUuwWyYzZ])') re_escaped = re.compile(r'\\(.)') Loading @@ -48,7 +47,7 @@ class TimeFormat(Formatter): # or time objects (against established django policy). if isinstance(obj, datetime.datetime): if is_naive(obj): self.timezone = LocalTimezone(obj) self.timezone = get_default_timezone() else: self.timezone = obj.tzinfo Loading
django/utils/dateparse.py +5 −4 Original line number Diff line number Diff line Loading @@ -8,8 +8,8 @@ import datetime import re from django.utils import six from django.utils.timezone import utc from django.utils.tzinfo import FixedOffset from django.utils.timezone import utc, get_fixed_timezone date_re = re.compile( r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$' Loading @@ -27,6 +27,7 @@ datetime_re = re.compile( r'(?P<tzinfo>Z|[+-]\d{2}:?\d{2})?$' ) def parse_date(value): """Parses a string and return a datetime.date. Loading Loading @@ -59,7 +60,7 @@ def parse_datetime(value): """Parses a string and return a datetime.datetime. This function supports time zone offsets. When the input contains one, the output uses an instance of FixedOffset as tzinfo. the output uses a timezone with a fixed offset from UTC. Raises ValueError if the input is well formatted but not a valid datetime. Returns None if the input isn't well formatted. Loading @@ -76,7 +77,7 @@ def parse_datetime(value): offset = 60 * int(tzinfo[1:3]) + int(tzinfo[-2:]) if tzinfo[0] == '-': offset = -offset tzinfo = FixedOffset(offset) tzinfo = get_fixed_timezone(offset) kw = dict((k, int(v)) for k, v in six.iteritems(kw) if v is not None) kw['tzinfo'] = tzinfo return datetime.datetime(**kw)
tests/model_regress/tests.py +3 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,7 @@ import unittest from django.core.exceptions import ValidationError from django.test import TestCase, skipUnlessDBFeature from django.utils import six from django.utils import tzinfo from django.utils.timezone import get_fixed_timezone from django.db import connection, router from django.db.models.sql import InsertQuery Loading Loading @@ -189,8 +189,8 @@ class ModelTests(TestCase): # Regression test for #10443. # The idea is that all these creations and saving should work without # crashing. It's not rocket science. dt1 = datetime.datetime(2008, 8, 31, 16, 20, tzinfo=tzinfo.FixedOffset(600)) dt2 = datetime.datetime(2008, 8, 31, 17, 20, tzinfo=tzinfo.FixedOffset(600)) dt1 = datetime.datetime(2008, 8, 31, 16, 20, tzinfo=get_fixed_timezone(600)) dt2 = datetime.datetime(2008, 8, 31, 17, 20, tzinfo=get_fixed_timezone(600)) obj = Article.objects.create( headline="A headline", pub_date=dt1, article_text="foo" ) Loading