1
0
mirror of https://github.com/django/django.git synced 2024-12-25 18:46:22 +00:00
django/tests/regressiontests/datetime_safe/tests.py

38 lines
1.2 KiB
Python
Raw Normal View History

r"""
>>> from datetime import date as original_date, datetime as original_datetime
>>> from django.utils.datetime_safe import date, datetime
>>> just_safe = (1900, 1, 1)
>>> just_unsafe = (1899, 12, 31, 23, 59, 59)
>>> really_old = (20, 1, 1)
>>> more_recent = (2006, 1, 1)
>>> original_datetime(*more_recent) == datetime(*more_recent)
True
>>> original_datetime(*really_old) == datetime(*really_old)
True
>>> original_date(*more_recent) == date(*more_recent)
True
>>> original_date(*really_old) == date(*really_old)
True
>>> original_date(*just_safe).strftime('%Y-%m-%d') == date(*just_safe).strftime('%Y-%m-%d')
True
>>> original_datetime(*just_safe).strftime('%Y-%m-%d') == datetime(*just_safe).strftime('%Y-%m-%d')
True
>>> date(*just_unsafe[:3]).strftime('%Y-%m-%d (weekday %w)')
'1899-12-31 (weekday 0)'
>>> date(*just_safe).strftime('%Y-%m-%d (weekday %w)')
'1900-01-01 (weekday 1)'
>>> datetime(*just_unsafe).strftime('%Y-%m-%d %H:%M:%S (weekday %w)')
'1899-12-31 23:59:59 (weekday 0)'
>>> datetime(*just_safe).strftime('%Y-%m-%d %H:%M:%S (weekday %w)')
'1900-01-01 00:00:00 (weekday 1)'
>>> date(*just_safe).strftime('%y') # %y will error before this date
'00'
>>> datetime(*just_safe).strftime('%y')
'00'
"""