Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected handling of dateModified & datePublished #624

Merged
merged 1 commit into from
May 7, 2024

Conversation

tomschr
Copy link
Collaborator

@tomschr tomschr commented May 7, 2024

Fix DOCTEAM#1367

This PR contains the following changes:

  • Combine separate json-ld-dateModified and json-ld-datePublished into json-ld-dateModified-and-Published.
    Produce only an entry, if dates are valid and if datePublished < dateModified
    Use first revhistory/revision/date for dateModified and last revhistory/revision/date for datePublished.
  • Revamp santize-date(date) template date can be any date in the format YYYY-M, YYYY-MM, YYYY-M-D, YYYY-MM-D, YYYY-M-DD, or YYYY-MM-DD. If the date doesn't conform to any of these formats, an empty string is returned.
  • Add new validate-date(date) template $date should be in the format of YYYY-MM-DDTHH:MMZ, but only the YYYY-MM-DD is checked. If the date is valid, true() is return, otherwise false()
  • Add compare-dates(date1, date2)
    Compare two dates lexicographically. Return -1 if date1 < date2; 0 if date1 == date2; 1 if date1 > date2.

In simple words, the stylesheet follows this approach:

  1. Retrieve the possible date elements from <revhistory>.
  2. Sanitize different formats into the consistent ISO format YYYY-MM-DDTHH:MMZ
  3. Validate the dates
  4. Compare the dates so it follows datePublished < dateModified
  5. If this is all correct, create the respective JSON-LD structure. If there are invalid dates, skip it.

Fix DOCTEAM#1367

* Combine separate json-ld-dateModified and json-ld-datePublished
  into json-ld-dateModified-and-Published
  Produce only an entry, if dates are valid and if
  datePublished < dateModified
  Use first revhistory/revision/date for dateModified and
  last revhistory/revision/date for datePublished.
* Revamp santize-date(date) template
  date can be any date in the format YYYY-M, YYYY-MM, YYYY-M-D,
  YYYY-MM-D, or YYYY-MM-DD.
  If the date doesn't conform to any of these formats, an
  empty string is returned
* Add new validate-date(date) template
  $date should be in the format of YYYY-MM-DDTHH:MMZ, but
  only the YYYY-MM-DD is checked.
  If the date is valid, true() is return, otherwise false()
* Add compare-dates(date1, date2)
  Compare two dates lexicographically.
  Return -1 if date1 < date2; 0 if date1 == date2; 1 if date1 > date2
@tomschr tomschr self-assigned this May 7, 2024
@tomschr tomschr merged commit 520e461 into main May 7, 2024
2 checks passed
@tomschr tomschr deleted the docteam1367-datehandling branch May 7, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant