chiark / gitweb /
Oops, forgot to commit. Lots of faffing arround with graphs, graphs will be added...
[familyTree.git] / familyTree / findYear.py
1 #!/usr/bin/python
2
3 import re
4
5 def find_year(date):
6
7         dates = date.split('/')
8
9         if len(dates)==3:
10                 year =  dates[2]
11
12         elif len(dates)==2:
13                 year =  dates[1]
14
15         elif len(dates)==1:
16                 year = dates[0]
17
18         else:
19                 year = 0
20
21         parts = year.split('-')
22
23         matches = re.search('[0-9]{1,4}',parts[0])
24         if matches==None:
25                 year =  0
26         else:
27                 year =  matches.group(0)
28
29
30         return year
31
32
33 def find_month(date):
34
35         dates = date.split('/')
36         if len(dates)==3:
37                 return dates[1]
38         if len(dates)==2:
39                 parts = date.split('-')
40                 matches = re.search('[0-9]{1,2}',parts[0])
41                 if matches == None:
42                         return 0
43                 else: 
44                         return matches.group(0)
45         else:
46                 return 0
47