File tree Expand file tree Collapse file tree 2 files changed +16
-9
lines changed
src/undate/converters/edtf Expand file tree Collapse file tree 2 files changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -54,24 +54,19 @@ def year_unspecified(self, items):
5454 return Tree (data = "year" , children = [value ])
5555
5656 def month_unspecified (self , items ):
57+ # combine multiple parts into a single string
5758 value = "" .join (self .get_values (items ))
5859 return Tree (data = "month" , children = [value ])
5960
6061 def day_unspecified (self , items ):
62+ # combine multiple parts into a single string
6163 value = "" .join (self .get_values (items ))
6264 return Tree (data = "day" , children = [value ])
6365
6466 def date_level1 (self , items ):
6567 return self .date (items )
6668
67- def year (self , items ):
68- # when the year is negative, there are two tokens
69- if len (items ) > 1 and items [0 ] == "-" :
70- # an anonymous token for the - and the integer year
71- year = items [1 ]
72- return Tree (data = "year" , children = [- year ])
73-
74- return Tree (data = "year" , children = [items [0 ]])
69+ # year (including negative years) use default transformation
7570
7671 def year_fivedigitsplus (self , items ):
7772 # strip off the leading Y and convert to integer
Original file line number Diff line number Diff line change 11import logging
22
33import pytest
4- from undate .converters .base import BaseDateConverter
4+ from undate .converters .base import BaseDateConverter , BaseCalendarConverter
55
66
77class TestBaseDateConverter :
@@ -62,3 +62,15 @@ class ISO8601DateFormat2(BaseDateConverter):
6262 assert len (BaseDateConverter .available_converters ()) != len (
6363 BaseDateConverter .subclasses ()
6464 )
65+
66+
67+ class TestBaseCalendarConverter :
68+ def test_not_implemented (self ):
69+ with pytest .raises (NotImplementedError ):
70+ BaseCalendarConverter ().min_month ()
71+ with pytest .raises (NotImplementedError ):
72+ BaseCalendarConverter ().max_month (1900 )
73+ with pytest .raises (NotImplementedError ):
74+ BaseCalendarConverter ().max_day (1900 , 12 )
75+ with pytest .raises (NotImplementedError ):
76+ BaseCalendarConverter ().to_gregorian (1900 , 12 , 31 )
You can’t perform that action at this time.
0 commit comments