Skip to content

Commit

Permalink
implemented : as date-separator in parser
Browse files Browse the repository at this point in the history
Per [jMyles](sdispater#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 <emattiza@gmail.com>
  • Loading branch information
emattiza committed Mar 21, 2017
1 parent d29cd2f commit 1bf66d7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pendulum/parsing/parser.py
Expand Up @@ -21,8 +21,8 @@ class Parser(object):
' (?P<classic>' # Classic date (YYYY-MM-DD) or ordinal (YYYY-DDD)
' (?P<year>\d{4})' # Year
' (?P<monthday>'
' (?P<monthsep>-|/)?(?P<month>\d{2})' # Month (optional)
' ((?P<daysep>-|/)?(?P<day>\d{1,2}))?' # Day (optional)
' (?P<monthsep>[-/:])?(?P<month>\d{2})' # Month (optional)
' ((?P<daysep>[-/:])?(?P<day>\d{1,2}))?' # Day (optional)
' )?'
' )'
' |'
Expand Down
12 changes: 12 additions & 0 deletions tests/parsing_test/test_parser.py
Expand Up @@ -561,3 +561,15 @@ def test_invalid(self):
text = '2012-W13-8'

self.assertRaises(ParserError, Parser().parse, text)

def test_exif_edge_case(self):
text = '2016:12:26 15:45:28'

parsed = Parser().parse(text)

self.assertEqual(2016, parsed['year'])
self.assertEqual(12, parsed['month'])
self.assertEqual(26, parsed['day'])
self.assertEqual(15, parsed['hour'])
self.assertEqual(45, parsed['minute'])
self.assertEqual(28, parsed['second'])

0 comments on commit 1bf66d7

Please sign in to comment.