Skip to content

Commit

Permalink
Fix parsing of dateTime input and format the parameter for the comman…
Browse files Browse the repository at this point in the history
…dline
  • Loading branch information
torse committed Jun 14, 2017
1 parent 14075ba commit 5e2ae86
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/wpsremote/computation_job_input.py
Expand Up @@ -42,7 +42,7 @@ def _validate_and_convert(self, value):
elif (self._type=='datetime'):
if self._formatter:
try:
date_value = datetime.datetime.strptime(str(value), self._formatter)
date_value = value.strftime(self._formatter)
return date_value
except:
pass
Expand Down Expand Up @@ -86,9 +86,9 @@ def set_value(self, value):
try:
res= self.validate()
if not res:
raise TypeError()
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)
except:
raise TypeError()
raise TypeError("cannot set value " + str(self._value) + " for parameter " + self.get_name() + " with type " + self._type)



Expand All @@ -103,7 +103,10 @@ def get_type(self):

def get_value_string(self):
if type(self._value) is list and len(self._value)==1:
return self._value[0]
if type(self._value[0]) is datetime.datetime:
return self._value[0].strftime(self._formatter)
else:
return self._value[0]
else:
return self._value

Expand Down

0 comments on commit 5e2ae86

Please sign in to comment.