chiark
/
gitweb
/
~naath
/
familyTree.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
improved handling of ordinary numbers and description of relations
[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
return dates[2]
11
12
if len(dates)==2:
13
return dates[1]
14
15
if len(dates)==1:
16
parts = date.split('-')
17
18
matches = re.search('[0-9]{1,4}',parts[0])
19
if matches==None:
20
return 0
21
else:
22
return matches.group(0)
23
24
return 0
25
26