adiwg / mdTranslator

Metadata translation tool built using Ruby
https://www.adiwg.org/mdTranslator/
The Unlicense
14 stars 12 forks source link

Interpret DateTime Precision and Adjust Format During a Write #249

Open dwalt opened 1 year ago

dwalt commented 1 year ago

Date and DateTime formatted date fields are used throughout mdJSON. However, DateTime is zero filled, often implying a precision that doesn't exist. For instance, Citation dates are DateTime but many users use it to define a year of publication. The DateTime format in this case reduces readability and implies a non-existent precision. The proposal is for mdTranslator writers to interpret the data and reformat the DateTime accordingly to reflect the precision of the data as input. By reformatting it in mdTranslator avoids conditional formatting in mdEditor and additional user input.

dwalt commented 1 year ago

Per discussion with Stakeholders, UTC offsets must also be considered. It is proposed to drop UTC offsets if precision of data in DateTime does not include a time entry. The mdJSON to CSDGM translation may be an example of how DateTime is currently reformatted to date only form in CSDGM.

It appears this requirement would be applicable to all writers. Development of a function to handle date time reformats may benefit in providing consistent, single application of logic.

hmaier-fws commented 1 year ago

See also related mdEditor issue adiwg/mdeditor#483

dwalt commented 1 year ago

ISO will accept either a DateTime for Date tag. The rules are as follows:

  1. If there is a time component, then write the date time in zero filled DateTime with UTC offset:

    2023-07-18T14:00:00.000+00:00
  2. If there is no time component, then truncate time including UTC offset and recast to Date. If date is year/month or year only then truncate accordingly. Technically you can truncate to century as well:

    2023-07-18 2023-07
  3. Follow rules above for ISO, HTML and sbJSON formats as defined above

  4. For CSDGM translation already exists

dwalt commented 1 year ago

CSDGM writer is outputting date content from mdJSON to include the utc offset as a time element. CSDGM does not support utc and therefore time should not appear in this use case.

jwaspin commented 7 months ago

https://github.com/adiwg/mdEditor/issues/205 https://github.com/adiwg/mdEditor/issues/246 https://github.com/adiwg/mdEditor/issues/483