Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Page MenuHomePhabricator

Please provide human readable timestamps in api response
Open, LowPublic

Description

In the API request:
https://m.wikidata.org/w/api.php?action=wbgetentities&format=json&ids=Q937&languages=en&props=descriptions%7Cclaims

{"hash":"a7e5bfde15440144baab73befd6eaddd22e0df12","snaktype":"value","property":"P580","datatype":"time","datavalue":{"value":{"time":"+00000001879-03-14T00:00:00Z","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727"},"type":"time"}}]

is one of the responses.
Could this be supplemented with a human readable string e.g.
{
"time":"+00000001879-03-14T00:00:00Z",
"msg": "14th March 1879"

Currently a frontend dev has to write /lots of/ code to do the above (see https://gerrit.wikimedia.org/r/#/c/184811/7/javascripts/modules/infobox/Infobox.js) so it would be better to return this via the API in the requested language.

Event Timeline

Jdlrobson raised the priority of this task from to Needs Triage.
Jdlrobson updated the task description. (Show Details)
Lydia_Pintscher set Security to None.
Lydia_Pintscher added subscribers: daniel, aude, JanZerebecki.

I guess datavalues could perhaps come with a default formatted value?
Or the option to also have a formatted value.

The current work around is to pass each datavalue into http://www.wikidata.org/w/api.php?action=help&modules=wbformatvalue

An alternative would be to do something similar to core, ie. do one query (get a list of entities) as some sort of generator and also run another module ie. formatvalues, also returning their formatted values in the same request!?

Lydia_Pintscher lowered the priority of this task from Medium to Low.Apr 23 2017, 3:48 PM

since 2016 there is a nice library which should prevent this lots of code:
https://github.com/date-fns/date-fns