Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into strptime-short-month-names
  • Loading branch information
serhiy-storchaka committed Oct 8, 2024
commit 684cb84b0e770d4ec22de174d21032a5c9768425
35 changes: 31 additions & 4 deletions Lib/test/test_strptime.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,14 +478,27 @@ def test_bad_timezone(self):
# * Year is not included: ha_NG.
# * Use non-Gregorian calendar: lo_LA, thai, th_TH.
#
# BUG: Generates invalid regexp for br_FR, csb_PL.
# BUG: Generates invalid regexp for br_FR, csb_PL, Arabic.
# BUG: Generates regexp that does not match the current date and time
# for fa_IR, gez_ER, gez_ET, lzh_TW, my_MM, or_IN, shn_MM, yo_NG.
@run_with_locales('LC_TIME', 'C', 'en_US', 'fr_FR', 'de_DE', 'ja_JP',
'he_IL', 'eu_ES', 'ar_AE', 'mfe_MU')
def test_date_time_locale(self):
# Test %c directive
self.roundtrip('%c', slice(0, 6))
now = time.time()
self.roundtrip('%c', slice(0, 6), time.localtime(now))
# 1 hour 20 minutes 30 seconds ago
self.roundtrip('%c', slice(0, 6), time.localtime(now - 4830))
# 12 hours ago
self.roundtrip('%c', slice(0, 6), time.localtime(now - 12*3600))
# different days of the week
for i in range(1, 7):
self.roundtrip('%c', slice(0, 6), time.localtime(now - i*24*3600))
# different months
for i in range(1, 12):
self.roundtrip('%c', slice(0, 6), time.localtime(now - i*30*24*3600))
# different year
self.roundtrip('%c', slice(0, 6), time.localtime(now - 366*24*3600))

# NB: Dates before 1969 do not roundtrip on some locales:
# bo_CN, bo_IN, dz_BT, eu_ES, eu_FR.
Expand All @@ -502,7 +515,16 @@ def test_date_time_locale2(self):
'he_IL', 'eu_ES', 'ar_AE')
def test_date_locale(self):
# Test %x directive
self.roundtrip('%x', slice(0, 3))
now = time.time()
self.roundtrip('%x', slice(0, 3), time.localtime(now))
# different days of the week
for i in range(1, 7):
self.roundtrip('%x', slice(0, 3), time.localtime(now - i*24*3600))
# different months
for i in range(1, 12):
self.roundtrip('%x', slice(0, 3), time.localtime(now - i*30*24*3600))
# different year
self.roundtrip('%x', slice(0, 3), time.localtime(now - 366*24*3600))

# NB: Dates before 1969 do not roundtrip on many locales, including C.
@unittest.skipIf(
Expand All @@ -527,7 +549,12 @@ def test_date_locale2(self):
@run_with_locales('LC_TIME', 'C', 'en_US', 'fr_FR', 'de_DE', 'ja_JP')
def test_time_locale(self):
# Test %X directive
self.roundtrip('%X', slice(3, 6))
now = time.time()
self.roundtrip('%X', slice(3, 6), time.localtime(now))
# 1 hour 20 minutes 30 seconds ago
self.roundtrip('%X', slice(3, 6), time.localtime(now - 4830))
# 12 hours ago
self.roundtrip('%X', slice(3, 6), time.localtime(now - 12*3600))

def test_percent(self):
# Make sure % signs are handled properly
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.