Skip to content

Commit 8dc70c0

Browse files
emattizasdispater
authored andcommitted
implemented : as date-separator in parser (#102)
Per [jMyles](#101) this adds a test in pytest format with a single example. Alters COMMON regex to include : as date-separator Signed-off-by: Evan Mattiza <[email protected]>
1 parent d29cd2f commit 8dc70c0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pendulum/parsing/parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ class Parser(object):
2121
' (?P<classic>' # Classic date (YYYY-MM-DD) or ordinal (YYYY-DDD)
2222
' (?P<year>\d{4})' # Year
2323
' (?P<monthday>'
24-
' (?P<monthsep>-|/)?(?P<month>\d{2})' # Month (optional)
25-
' ((?P<daysep>-|/)?(?P<day>\d{1,2}))?' # Day (optional)
24+
' (?P<monthsep>[-/:])?(?P<month>\d{2})' # Month (optional)
25+
' ((?P<daysep>[-/:])?(?P<day>\d{1,2}))?' # Day (optional)
2626
' )?'
2727
' )'
2828
' |'

tests/parsing_test/test_parser.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,3 +561,15 @@ def test_invalid(self):
561561
text = '2012-W13-8'
562562

563563
self.assertRaises(ParserError, Parser().parse, text)
564+
565+
def test_exif_edge_case(self):
566+
text = '2016:12:26 15:45:28'
567+
568+
parsed = Parser().parse(text)
569+
570+
self.assertEqual(2016, parsed['year'])
571+
self.assertEqual(12, parsed['month'])
572+
self.assertEqual(26, parsed['day'])
573+
self.assertEqual(15, parsed['hour'])
574+
self.assertEqual(45, parsed['minute'])
575+
self.assertEqual(28, parsed['second'])

0 commit comments

Comments
 (0)