Fixed a typo and improved Swedish Calendar.

svn: r16642
This commit is contained in:
Peter Landgren 2011-02-17 08:34:48 +00:00
parent 1b08fdb508
commit 55fabe2187

View File

@ -96,18 +96,20 @@ def julian_valid(date_tuple):
def swedish_valid(date_tuple): def swedish_valid(date_tuple):
""" Checks if date_tuple is a valid date in Swedish Calendar """ """ Checks if date_tuple is a valid date in Swedish Calendar """
valid = gregorian_valid(date_tuple) valid_J = julian_valid(date_tuple)
# not sure how <= and >= works with tuples???
date_tuple = (date_tuple[2], date_tuple[1], date_tuple[0]) date_tuple = (date_tuple[2], date_tuple[1], date_tuple[0])
if date_tuple <= (1700, 2, 28): # Swedish calendar starts as Julian 1700-03-01 and ends 1712-03-01 as Julian
valid = False if date_tuple >= (1700, 2, 29) and date_tuple < (1712, 3, 1):
if date_tuple == (1700, 2, 29): # leapday 1700 was skipped if date_tuple == (1712, 2, 30): # extra day was inserted 1712, not valid Julian
valid = False return True
if date_tuple == (1712, 2, 30): # extra day was inserted 1712 if valid_J:
valid = True if date_tuple == (1700, 2, 29): # leapday 1700 was skipped
if date_tuple >= (1712, 3, 1): # back to julian return False
valid = False return True
return valid else:
return False
else:
return False
def french_valid(date_tuple): def french_valid(date_tuple):
""" Checks if date_tuple is a valid date in French Calendar """ """ Checks if date_tuple is a valid date in French Calendar """
@ -216,7 +218,7 @@ class DateParser(object):
"januari" : 1, "februari" : 2, "januari" : 1, "februari" : 2,
"mars" : 3, "april" : 4, "mars" : 3, "april" : 4,
"maj" : 5, "juni" : 6, "maj" : 5, "juni" : 6,
"juli" : 7, "augisti" : 8, "juli" : 7, "augusti" : 8,
"september" : 9, "oktober" : 10, "september" : 9, "oktober" : 10,
"november" : 11, "december" : 12, "november" : 11, "december" : 12,
} }