Change format "utc-millisec" to "date-time"

Created on 27 October 2021, over 3 years ago
Updated 14 May 2025, 6 days ago

Problem/Motivation

Timestamps provided via JSON:API are in ISO8601 format, but the schema specifies that they are in "utc-millisec" format. For example:

"created": {
  "type": "number",
  "title": "Authored on",
  "format": "utc-millisec",
  "description": "The time that the log was created."
},

The "utc-millisec" format seems a little obscure, but I was able to find the specification here:

utc-millisec This SHOULD be the difference, measured in
milliseconds, between the specified time and midnight, 00:00 of
January 1, 1970 UTC. The value SHOULD be a number (integer or
float).

That does not describe, however, the ISO format being sent via JSON:API, which looks like "2021-09-24T01:53:22+00:00", whereas that same timestamp rendered in "utc-millisec" would be the int 1632448402000. Also, the schema type should be "string", not "number". As far as I know, the "format" keyword does not apply to numbers, only strings.

The built-in JSON Schema format "date-time" seems to be the correct format to use for the timestamps given by JSON:API. It also seems to have broader adoption than "utc-millisec", from what I can tell.

Steps to reproduce

Go to: https://test.farmos.dev/api/log/activity/resource/schema

Proposed resolution

Change the format "utc-millisec" to "date-time", and the type "number" to "string" in DataDefinitionTimestampNormalizer.

@m.stenta or I will provide a patch in the comments.

Remaining tasks

I think the patch is all?

User interface changes

None.

API changes

All timestamps with format "utc-millisec" will change to "date-time".

Data model changes

I don't think any.

πŸ› Bug report
Status

Needs review

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States jgaehring New York City

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024