Page MenuHomePhabricator

(MS 6) Create FormatValueRepository
Closed, ResolvedPublic

Description

The ParseValueRepository created in T277038 turns the user input of 1920-02 into something like +1920-02-00T00:00:00Z. That is not nice and we don't want to show that to the user. Therefore, we need to do another API call to format that value and turn it into something like February 1920. This is also what happens on Wikidata.

Query example: https://www.wikidata.org/w/api.php?action=wbformatvalue&format=json&datavalue={"value":{"after":0,"before":0,"calendarmodel":"http://www.wikidata.org/entity/Q1985727","precision":10,"time":"+1920-02-00T00:00:00Z","timezone":0},"type":"time"}&generate=text/plain&property=P577&errorformat=plaintext&uselang=en&options={"lang":"en"}
API help: https://www.wikidata.org/w/api.php?action=help&modules=wbformatvalue

That is what the expected datavalue lookes like

{
	"value": {
		"time": "+1920-02-00T00:00:00Z",
		"timezone": 0,
		"before": 0,
		"after": 0,
		"precision": 10,
		"calendarmodel": "http://www.wikidata.org/entity/Q1985727"
	},
	"type": "time"
}