API /v3/build/:buildId inconsistent time format

Description

The purpose of this topic is to ask for clarification on a date format inconsistency on the /v3/build/:buildId endpoint.

Example:

    {
       ...
       "started_at":"2019-10-03T14:53:57Z",
       "finished_at":"2019-10-03T14:54:55Z",
       ... 
       "commit":{
            ...
            "committed_at":"2019-10-03T14:53:00Z"
        },
        ...
       "updated_at":"2019-10-03T14:54:55.687Z"
    }

As it can be seen the updated_at value has a date format that includes milliseconds, while all other dates do not. This may present some troubles for some JSON parsers.

The question is: is this behavior intended?

Thanks for the report. This looks like a bug to me. We’ll take a look soon.

1 Like

For the record, if you use the JavaScript method to convert a date in JSON using the method toJSON of the class Date (the documentation is here), you will obtain a string with milliseconds: 2019-10-24T16:08:19.467Z

As I can see from the source, they use two functions to format dates: format_date (outputs without ms) and json_format_time_with_ms (outputs with ms). (Both use strftime.) Basically, they need to decide which of the two formats they want to use.

Imprint