File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ def is_float(s):
327327
328328
329329# Return True if s is an iso date such as `2019-12-12`
330- is_iso_date = re .compile (r'19|20[0-9]{2}-[0-1][0-9]-[0-3]?[1 -9]' ).match
330+ is_iso_date = re .compile (r'( 19|20) [0-9]{2}-[0-1][0-9]-[0-3][0 -9]' ).match
331331
332332SaneDumper .add_representer (int , SaneDumper .string_dumper )
333333SaneDumper .add_representer (dict , SaneDumper .ordered_dumper )
Original file line number Diff line number Diff line change @@ -137,6 +137,22 @@ def test_load_ignore_aliases(self):
137137 ])
138138 assert expected == result
139139
140+ def test_is_iso_date (self ):
141+ assert saneyaml .is_iso_date ('1994-01-01' )
142+ assert saneyaml .is_iso_date ('2004-01-01' )
143+ assert not saneyaml .is_iso_date ('1800-01-01' )
144+ assert not saneyaml .is_iso_date ('2100-01-01' )
145+ assert saneyaml .is_iso_date ('2004-01-30' )
146+ assert not saneyaml .is_iso_date ('2004-01-40' )
147+ assert not saneyaml .is_iso_date ('2004-01-4' )
148+ assert not saneyaml .is_iso_date ('2004-01-3a' )
149+ assert not saneyaml .is_iso_date ('1994-01-1' )
150+ assert not saneyaml .is_iso_date ('1994-1-1' )
151+ assert not saneyaml .is_iso_date ('193' )
152+ # Hey, nothing's perfect
153+ assert saneyaml .is_iso_date ('2003-02-29' )
154+ assert saneyaml .is_iso_date ('2004-01-35' )
155+
140156
141157safe_chars = re .compile (r'[\W_]' , re .MULTILINE )
142158
You can’t perform that action at this time.
0 commit comments