Permalink
Browse files

Replaced all of the date formatting lines with a call to the formatDa…

…te function in utils.py
  • Loading branch information...
1 parent d600582 commit f0973f97275d9c0aae9fe0424f9bfcdae0911528 @anusharanganathan anusharanganathan committed Jun 25, 2012
View
8 rdfdatabank/lib/utils.py
@@ -449,8 +449,12 @@ def extract_metadata(item):
return dict(m)
def formatDate(dt):
- dt_obj = parse(dt, dayfirst=True, yearfirst=False)
- dt_human = dt_obj.strftime("%B %d %Y, %I:%M %p")
+ dt_human = dt
+ try:
+ dt_obj = parse(dt, dayfirst=True, yearfirst=False)
+ dt_human = dt_obj.strftime("%B %d %Y, %I:%M %p")
+ except:
+ return dt
return dt_human
def getSiloModifiedDate(silo_name):
View
16 rdfdatabank/templates/datasetview.html
@@ -109,15 +109,13 @@
<h2>Access Information</h2>
<div class="dataset_info">
% if c.embargos and c.current in c.embargos and c.embargos[c.current]:
- <%
- from dateutil.parser import parse
- from time import strftime
- c.emb = c.embargos[c.current]
- dt_human = c.emb[1]
- if c.emb[1] and c.emb[1].strip():
- dt_obj = parse(c.emb[1].strip(), dayfirst=True, yearfirst=False)
- dt_human = dt_obj.strftime('%B %d %Y, %I:%M %p')
- %>
+<%
+from rdfdatabank.lib.utils import formatDate
+c.emb = c.embargos[c.current]
+dt_human = c.emb[1]
+if dt_human and dt_human.strip():
+ dt_human = formatDate(dt_human)
+%>
% if c.emb[0] == True or c.emb[0] == 1 or (isinstance(c.emb[0], basestring) and c.emb[0].strip().lower() in ['true', '1']):
% if (isinstance(c.emb[1], basestring) and c.emb[1].strip()):
Data package is embargoed until ${dt_human}. Only the metadata is openly accessible.
View
6 rdfdatabank/templates/embargo_form.html
@@ -14,12 +14,8 @@
% if c.embargos[c.current][1]:
<%
from rdfdatabank.lib.utils import formatDate
- ##dateutil.parser import parse
- ##from time import strftime
dt_human = c.embargos[c.current][1]
- if c.embargos[c.current][1].strip():
- ##dt_obj = parse(c.embargos[c.current][1].strip(), dayfirst=True, yearfirst=False)
- ##dt_human = dt_obj.strftime('%Y-%m-%d %H:%M:%S')
+ if dt_human and dt_human.strip():
dt_human = formatDate(dt_human)
%>
<label for="emu">Embargoed until (date)</label>
View
16 rdfdatabank/templates/list_of_datasets.html
@@ -97,15 +97,13 @@
<td><ul><li><a href="/${c.silo_name}/datasets/${item}"> ${item}</a></li></ul></td>
<td>
% if c.embargos and item in c.embargos and c.embargos[item]:
- <%
- c.emb = c.embargos[item]
- from dateutil.parser import parse
- from time import strftime
- dt_human = c.emb[1]
- if c.emb[1] and c.emb[1].strip():
- dt_obj = parse(c.emb[1].strip(), dayfirst=True, yearfirst=False)
- dt_human = dt_obj.strftime('%B %d %Y, %I:%M %p')
- %>
+<%
+from rdfdatabank.lib.utils import formatDate
+c.emb = c.embargos[item]
+dt_human = c.emb[1]
+if dt_human and dt_human.strip():
+ dt_human = formatDate(dt_human)
+%>
% if c.emb[0] == True or c.emb[0] == 1 or (isinstance(c.emb[0], basestring) and c.emb[0].strip().lower() in ['true', '1']):
% if (isinstance(c.emb[1], basestring) and c.emb[1].strip()):
Data package is embargoed until ${dt_human}

0 comments on commit f0973f9

Please sign in to comment.