Refs #32738, Refs #29600, Refs #29595 -- Removed unused django.utils.datetime_safe.time().

Unused since c72dde41e6.
This commit is contained in:
Nick Pope 2021-05-11 14:03:55 +01:00 committed by Carlton Gibson
parent 1061f52436
commit 44accb066a
2 changed files with 6 additions and 22 deletions

View File

@ -7,10 +7,8 @@
# >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A") # >>> datetime_safe.date(10, 8, 2).strftime("%Y/%m/%d was a %A")
# '0010/08/02 was a Monday' # '0010/08/02 was a Monday'
import time as ttime import time
from datetime import ( from datetime import date as real_date, datetime as real_datetime
date as real_date, datetime as real_datetime, time as real_time,
)
from django.utils.regex_helper import _lazy_re_compile 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) return date(self.year, self.month, self.day)
class time(real_time):
pass
def new_date(d): def new_date(d):
"Generate a safe date from a datetime.date object." "Generate a safe date from a datetime.date object."
return date(d.year, d.month, d.day) return date(d.year, d.month, d.day)
@ -88,10 +82,10 @@ def strftime(dt, fmt):
# Move to around the year 2000 # Move to around the year 2000
year = year + ((2000 - year) // 28) * 28 year = year + ((2000 - year) // 28) * 28
timetuple = dt.timetuple() timetuple = dt.timetuple()
s1 = ttime.strftime(fmt, (year,) + timetuple[1:]) s1 = time.strftime(fmt, (year,) + timetuple[1:])
sites1 = _findall(s1, str(year)) 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)) sites2 = _findall(s2, str(year + 28))
sites = [] sites = []

View File

@ -1,10 +1,7 @@
from datetime import ( from datetime import date as original_date, datetime as original_datetime
date as original_date, datetime as original_datetime,
time as original_time,
)
from django.test import SimpleTestCase 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): class DatetimeTests(SimpleTestCase):
@ -13,7 +10,6 @@ class DatetimeTests(SimpleTestCase):
self.percent_y_safe = (1900, 1, 1) # >= 1900 required on Windows. self.percent_y_safe = (1900, 1, 1) # >= 1900 required on Windows.
self.just_safe = (1000, 1, 1) self.just_safe = (1000, 1, 1)
self.just_unsafe = (999, 12, 31, 23, 59, 59) self.just_unsafe = (999, 12, 31, 23, 59, 59)
self.just_time = (11, 30, 59)
self.really_old = (20, 1, 1) self.really_old = (20, 1, 1)
self.more_recent = (2006, 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') 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): 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_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)') 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)' 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 # %y will error before this date
self.assertEqual(date(*self.percent_y_safe).strftime('%y'), '00') self.assertEqual(date(*self.percent_y_safe).strftime('%y'), '00')
self.assertEqual(datetime(*self.percent_y_safe).strftime('%y'), '00') self.assertEqual(datetime(*self.percent_y_safe).strftime('%y'), '00')