diff --git a/src/coscine/__about__.py b/src/coscine/__about__.py index 50b59a23304de0d1e02f11a2a5f6b758720ac2cf..a9705479e43df5e0bc78506f2fb94b2ea3987579 100644 --- a/src/coscine/__about__.py +++ b/src/coscine/__about__.py @@ -30,7 +30,7 @@ __title__ = "coscine" # Current package version # Do not set version to 1.0.0 before update to Coscine API version 2 -__version__ = "0.9.3" +__version__ = "0.9.4" # Short package description __summary__ = ( diff --git a/src/coscine/form.py b/src/coscine/form.py index f759aee27190e6062cecce339165bedfe3cb1be0..87ec1869d1d2c4ba0c40338141dd1491e058c291 100644 --- a/src/coscine/form.py +++ b/src/coscine/form.py @@ -580,21 +580,29 @@ class InputForm: ############################################################################### + def xsd_type(self, key: str) -> str: + """ + Returns the xsd type identifier for a given field. + """ + datatype = self.properties(key).datatype + if datatype and datatype.startswith("http:"): + datatype = f"xsd:{urllib.parse.urlparse(datatype)[-1]}" + return datatype + ############################################################################### def datatype(self, key: str) -> type: """ Returns the datatype for a given field (which may be None). """ - datatype = self.properties(key).datatype - if datatype and datatype.startswith("http:"): - datatype = f"xsd:{urllib.parse.urlparse(datatype)[-1]}" if self.is_controlled(key): return str - return self._xsd_typeof(datatype) + else: + datatype: str = self.xsd_type(key) + return self._xsd_typeof(datatype) ############################################################################### - +# FIXME: Lots of xsd types still unhandled, especially datetime formats def type_format(self, key: str) -> str: """ Returns the format for a datatype of a field. @@ -608,7 +616,10 @@ class InputForm: if datatype == float: return "%f" if datatype == datetime: - return "%Y-%m-%d" + if self.xsd_type(key) == "xsd:dateTime": + return "%Y-%m-%dT%H:%M:%S" + else: + return "%Y-%m-%d" return "Invalid Format" ###############################################################################