From d41233259725a6a463193f6562cd325686ea9d37 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 10 Nov 2004 04:20:47 +0000 Subject: [PATCH] * src/DateParser.py: Handle month=12 in gregorian_valid svn: r3718 --- ChangeLog | 3 +++ src/DateParser.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9a406346..531950c34 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2004-11-09 Don Allingham + * src/DateParser.py: Handle month=12 in gregorian_valid + 2004-11-09 Alex Roitman * src/WriteGedcom.py: Remove extraneous import. diff --git a/src/DateParser.py b/src/DateParser.py index 20c22883e..0216277a6 100644 --- a/src/DateParser.py +++ b/src/DateParser.py @@ -49,18 +49,21 @@ import Date # Top-level module functions # #------------------------------------------------------------------------- +_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] + def gregorian_valid(date_tuple): day = date_tuple[0] month = date_tuple[1] valid = True - if month > 12: - valid = False - elif day > _max_days[month]: + try: + if month > 12: + valid = False + elif day > _max_days[month-1]: + valid = False + except: valid = False return valid -_max_days = [ 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 ] - #------------------------------------------------------------------------- # # Parser class