chiark / gitweb /
Oops, forgot to commit. Lots of faffing arround with graphs, graphs will be added...
[familyTree.git] / familyTree / findYear.py
index 3b3e8dd82d8adaf39ddc6e91d20e18a308e93135..873d269da6ce017db0f7158400e387550e077ace 100755 (executable)
@@ -7,21 +7,27 @@ def find_year(date):
        dates = date.split('/')
 
        if len(dates)==3:
-               return dates[2]
+               year =  dates[2]
 
-       if len(dates)==2:
-               return dates[1]
+       elif len(dates)==2:
+               year =  dates[1]
 
-       if len(dates)==1:
-               parts = date.split('-')
+       elif len(dates)==1:
+               year = dates[0]
+
+       else:
+               year = 0
+
+       parts = year.split('-')
+
+       matches = re.search('[0-9]{1,4}',parts[0])
+       if matches==None:
+               year =  0
+       else:
+               year =  matches.group(0)
 
-               matches = re.search('[0-9]{1,4}',parts[0])
-               if matches==None:
-                       return 0
-               else:
-                       return matches.group(0)
 
-       return 0
+       return year
 
 
 def find_month(date):