Permalink
Browse files

Fix genbank date parsing to catch more edge cases

  • Loading branch information...
trvrb committed Jan 5, 2018
1 parent 93bf979 commit 98edf26b9cc2af424f2d4700f7020be6524446ca
Showing with 7 additions and 1 deletion.
  1. +7 −1 vdb/parse.py
View
@@ -357,7 +357,13 @@ def convert_gb_date(self, collection_date):
if N_fields == 1:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%Y'), '%Y-XX-XX')
elif N_fields == 2:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%b-%Y'), '%Y-%m-XX')
if collection_date.split('-')[0].isdigit():
if int(collection_date.split('-')[0]) < 13:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%m-%Y'), '%Y-%m-XX')
else:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%Y-%m'), '%Y-%m-XX')
else:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%b-%Y'), '%Y-%m-XX')
elif N_fields == 3:
if int(collection_date.split('-')[0]) < 32:
return datetime.datetime.strftime(datetime.datetime.strptime(collection_date,'%d-%b-%Y'), '%Y-%m-%d')

0 comments on commit 98edf26

Please sign in to comment.