From 323ac9257fa0f8d426da5052e4098b5537512c31 Mon Sep 17 00:00:00 2001 From: Doug Blank Date: Sat, 27 Dec 2008 21:31:16 +0000 Subject: [PATCH] Added len to Span class, and added an is_valid method to date. is_valid similar to is_regular, but allows partial dates svn: r11528 --- src/gen/lib/date.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gen/lib/date.py b/src/gen/lib/date.py index 8ea68b93c..564a0ef4b 100644 --- a/src/gen/lib/date.py +++ b/src/gen/lib/date.py @@ -111,6 +111,9 @@ class Span: return False return self.diff_tuple > other.diff_tuple + def __len__(self): + return len(self.diff_tuple) + #------------------------------------------------------------------------- # @@ -904,6 +907,12 @@ class Date: """ return self.modifier != Date.MOD_TEXTONLY + def is_valid(self): + """ + Return true if any part of the date is valid. + """ + return self.modifier != Date.MOD_TEXTONLY and self.sortval != 0 + def get_stop_year(self): """ Return the day of the year associated with the second part of a