open-contracting / european-union-support

Support scripts for TED mapping
BSD 3-Clause "New" or "Revised" License
9 stars 3 forks source link

OCDS date vs. xsd:date #66

Closed ColinMaudry closed 3 years ago

ColinMaudry commented 3 years ago

eForms uses xsd:date datatype to express dates that don't require a time. According to the XML Schema recommendation, an xsd:date is the date portion of an xsd:dateTime object, with the possibility to add an indication of the timezone.

Valid examples of xsd:date:

Question: is this datatype fully compatible with OCDS date, or does a time portion must be added? I see that in the EU standard forms guidance dates (e.g. "20191127") are mapped as-is, without conversion.

Ideally we should require a conversion of the dates both in eForms and SF guidance so that they match the OCDS date format: YYYY-MM-DDThh:mm:ssTZ

What do you think @jpmckinney?

ColinMaudry commented 3 years ago

In SF common guidance it's indicated a time component must be added, but it doesn't mention the reformatting of the date component: https://standard.open-contracting.org/profiles/eu/latest/en/operations/#set-time-components

jpmckinney commented 3 years ago

I'm confused. xsd:date is 2019-11-27, not 20191127, no? If so, the only necessary reformatting is to remove the optional timezone, which I was not aware of. Anyhow, the implementer will get validation errors if they don't format the date correctly.

http://books.xmlschemata.org/relaxng/ch19-77041.html

ColinMaudry commented 3 years ago

Standard forms use YYYYMMDD, eForms uses xsd:date.

In our guidance for standard forms, we mention that a time component must be added, but say nothing about the date component that should be reformatted (YYYYMMDD => YYYY-MM-DD).

I take note that for eForms, the reformatting will consist in removing the optional timezone and add the time component.

ColinMaudry commented 3 years ago

I think we should move this issue to the european-union-support repository.

jpmckinney commented 3 years ago

Standard forms use YYYYMMDD, eForms uses xsd:date.

Aha, so yes, you will need to edit this file (it's in the profile itself, rather than european-union-support): https://github.com/open-contracting-extensions/european-union/blob/latest/docs/operations.md

ColinMaudry commented 3 years ago

I can't remember where I saw that standard forms use YYYYMMDD... The TED XML data samples I have from 2019 use YYYY-MM-DD. Here is the XML Schema declaration in standard form schemas that apply to all the date elements I could find:

<xs:simpleType name="date_full">
        <xs:annotation>
            <xs:documentation>Format (19|20)yy-mm-dd</xs:documentation>
        </xs:annotation>
        <xs:restriction base="xs:date">
            <xs:pattern value="(19|20).{8}"/>
        </xs:restriction>
    </xs:simpleType>

An xs:restriction is used to constrain an existing type. In this case I understand that a date_full element must conform to xs:date, with the additional constrain to start with "19" or "20" (20th or 21st century dates).

I close it for now, unless I find where I saw this YYYYMMDD format.