diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py index 8c87c825d6..c732f29ef1 100644 --- a/django/utils/datetime_safe.py +++ b/django/utils/datetime_safe.py @@ -7,10 +7,8 @@ # >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A") # '0010/08/02 was a Monday' -import time as ttime -from datetime import ( - date as real_date, datetime as real_datetime, time as real_time, -) +import time +from datetime import date as real_date, datetime as real_datetime from django.utils.regex_helper import _lazy_re_compile @@ -34,10 +32,6 @@ class datetime(real_datetime): return date(self.year, self.month, self.day) -class time(real_time): - pass - - def new_date(d): "Generate a safe date from a datetime.date object." return date(d.year, d.month, d.day) @@ -88,10 +82,10 @@ def strftime(dt, fmt): # Move to around the year 2000 year = year + ((2000 - year) // 28) * 28 timetuple = dt.timetuple() - s1 = ttime.strftime(fmt, (year,) + timetuple[1:]) + s1 = time.strftime(fmt, (year,) + timetuple[1:]) sites1 = _findall(s1, str(year)) - s2 = ttime.strftime(fmt, (year + 28,) + timetuple[1:]) + s2 = time.strftime(fmt, (year + 28,) + timetuple[1:]) sites2 = _findall(s2, str(year + 28)) sites = [] diff --git a/tests/utils_tests/test_datetime_safe.py b/tests/utils_tests/test_datetime_safe.py index 56eec838fa..049a0dea13 100644 --- a/tests/utils_tests/test_datetime_safe.py +++ b/tests/utils_tests/test_datetime_safe.py @@ -1,10 +1,7 @@ -from datetime import ( - date as original_date, datetime as original_datetime, - time as original_time, -) +from datetime import date as original_date, datetime as original_datetime from django.test import SimpleTestCase -from django.utils.datetime_safe import date, datetime, time +from django.utils.datetime_safe import date, datetime class DatetimeTests(SimpleTestCase): @@ -13,7 +10,6 @@ class DatetimeTests(SimpleTestCase): self.percent_y_safe = (1900, 1, 1) # >= 1900 required on Windows. self.just_safe = (1000, 1, 1) self.just_unsafe = (999, 12, 31, 23, 59, 59) - self.just_time = (11, 30, 59) self.really_old = (20, 1, 1) self.more_recent = (2006, 1, 1) @@ -30,10 +26,6 @@ class DatetimeTests(SimpleTestCase): original_datetime(*self.just_safe).strftime('%Y-%m-%d'), datetime(*self.just_safe).strftime('%Y-%m-%d') ) - self.assertEqual( - original_time(*self.just_time).strftime('%H:%M:%S'), time(*self.just_time).strftime('%H:%M:%S') - ) - def test_safe_strftime(self): self.assertEqual(date(*self.just_unsafe[:3]).strftime('%Y-%m-%d (weekday %w)'), '0999-12-31 (weekday 2)') self.assertEqual(date(*self.just_safe).strftime('%Y-%m-%d (weekday %w)'), '1000-01-01 (weekday 3)') @@ -45,8 +37,6 @@ class DatetimeTests(SimpleTestCase): datetime(*self.just_safe).strftime('%Y-%m-%d %H:%M:%S (weekday %w)'), '1000-01-01 00:00:00 (weekday 3)' ) - self.assertEqual(time(*self.just_time).strftime('%H:%M:%S AM'), '11:30:59 AM') - # %y will error before this date self.assertEqual(date(*self.percent_y_safe).strftime('%y'), '00') self.assertEqual(datetime(*self.percent_y_safe).strftime('%y'), '00')