From: Diane Trout Date: Thu, 13 Dec 2012 19:40:10 +0000 (-0800) Subject: Use specific time formatting instead of locale '%c' X-Git-Url: http://woldlab.caltech.edu/gitweb/?p=htsworkflow.git;a=commitdiff_plain;h=bb26a3614b9930c7231a86ac93100fc4419283a9 Use specific time formatting instead of locale '%c' For some reason under my current configuration the locale formatter didn't work. Since it's probably better to actually set a known format for the xml files, I manually coded the appropriate string parser format. --- diff --git a/htsworkflow/pipelines/gerald.py b/htsworkflow/pipelines/gerald.py index e0d84cf..03c7d10 100644 --- a/htsworkflow/pipelines/gerald.py +++ b/htsworkflow/pipelines/gerald.py @@ -104,7 +104,7 @@ class Gerald(Alignment): timestamp = self.tree.findtext('ChipWideRunParameters/TIME_STAMP') if timestamp is not None: - epochstamp = time.mktime(time.strptime(timestamp, '%c')) + epochstamp = time.mktime(time.strptime(timestamp)) return datetime.fromtimestamp(epochstamp) return super(Gerald, self)._get_date() date = property(_get_date) @@ -187,7 +187,10 @@ class CASAVA(Alignment): return None time_element = self.tree.xpath('TIME_STAMP') if len(time_element) == 1: - return datetime.strptime(time_element[0].text, '%c') + timetuple = time.strptime( + time_element[0].text.strip(), + "%a %d %b %Y %I:%M:%S %p") + return datetime(*timetuple[:6]) return super(CASAVA, self)._get_date() date = property(_get_date)