Skip to content

Commit 6aa39aa

Browse files
committed
fix: Corner case where month was detected as 00
1 parent 96dadf0 commit 6aa39aa

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

normfn

+2-2
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,8 @@ def datetime_prefix(args, non_extension, filename):
400400
+ "|"
401401
+ "|".join(map(insensitiveize, calendar.month_abbr[1:13]))
402402
)
403-
MONTH = r"(0\d|1[012]|[1-9](?!\d)|" + MONTH_NAMES_ONLY + ")"
404-
DAY = r"([012]\d|3[01]|[1-9](?!\d))"
403+
MONTH = r"(0[1-9]|1[012]|[1-9](?!\d)|" + MONTH_NAMES_ONLY + ")"
404+
DAY = r"(0[1-9]|[12]\d|3[01]|[1-9](?!\d))"
405405
HOUR = r"([01]\d|2[0123])"
406406
MINUTE = SECOND = r"[012345]\d"
407407

tests/Direct/test_Direct_Basic.py

+9
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,15 @@ def test_month_name_year_reversed(self):
257257
self.assertEqual(1, self.directoryFileCount(self.workingDir))
258258
self.assertEqual('', error)
259259

260+
def test_day_month_name_year(self):
261+
filename = os.path.join(self.workingDir, 'Blah46_002004_XYZ_20_November_2015.txt')
262+
self.touch(filename)
263+
error = self.invokeDirectly([filename])
264+
self.assertFalse(os.path.exists(filename))
265+
self.assertTrue(os.path.exists(os.path.join(self.workingDir, '2015-11-20-Blah46_002004_XYZ.txt')))
266+
self.assertEqual(1, self.directoryFileCount(self.workingDir))
267+
self.assertEqual('', error)
268+
260269
def test_abbr_month_insensitive_name(self):
261270
filename = os.path.join(self.workingDir, 'Blah 25 jan 2015.txt')
262271
self.touch(filename)

0 commit comments

Comments
 (0)