Page MenuHomePhabricator

Autofill dates
Closed, ResolvedPublic


Parameters of the type "date" should have some way of autofilling with today's date. They shouldn't autofill automatically without any user input, because this will cause unexpected edits. But autofilling should be made as simple as possible.

The difficulty is that different wikis and even different parameters in different templates may have different conventions as to the preferred date format. However, it's also possible that there is already a cross-wiki convention (I just don't know), given that the TemplateData documentation suggests yyyy-mm-dd

Using the default date manager of the browsers (<input type="date">) doesn't work because it inserts dates in its own format (dd/mm/yyyy). It also breaks the current layout.

The temporary solution is showing the current date as a placeholder with the format recommended by TemplateData, yyyy-mm-dd. This has the advantage of not forcing any format, so each wiki may use their preferred format.

Maybe the best solution is having a button to the right of the date fields that autofills the date, and set the preferred date format from a configuration option, so that it can vary per wiki (but not per template or per parameter).

Event Timeline

The proper date format can be specified at parameter level by using the Map object of TemplateData.

Change 355907 had a related patch set uploaded (by Sophivorus; owner: Sophivorus):
[wikipedia/gadgets/ProveIt@master] Add Today button on date fields to insert the current date

Change 355907 merged by Sophivorus:
[wikipedia/gadgets/ProveIt@master] Add Today button on date fields to insert the current date

Sophivorus claimed this task.

I implemented the Today button. It just adds the current date in format yyyy-mm-dd, which is the preferred format according to TemplateData documentation and English Wikipedia documentation. If more control over the format is requested, I'll add it, but I won't complicate stuff unnecessarily.

I understand that the {{{df}}} parameter allows one to specify the date, so as to be able to have all dates uniform regardless of how they are entered. Maybe it would be a good idea to be able to find whether this is being used and if so what it is set to?

That makes sense, but in order to avoid hardcoding the parameter name (which would only work for the English Wikipedia) we'd need to tell ProveIt which is the date format parameter through the maps object of the template data. For example, the maps object of the template data of the Cite book template could look something like this:

"date-format-parameter": "df"

This would be telling ProveIt that the "df" parameter is the date-format parameter. If this parameter is set, then format the date according to it. This would allow ProveIt to properly format the date at the reference-level.

However, if the parameter ISN´T set, then there should be a way to set the date format at the template-level. Again the maps object is the solution:

"date-format": "dmy",
"date-format-parameter": "df"

This would mean: if the "df" parameter isn't set, format the date according to "date-format" parameter of the maps object (in this case, day-month-year).

Ah, but the date format should also be configurable at the wiki-level! So when initializing the gadget at MediaWiki:Gadget-ProveIt.js, we should be able to set the preferred date format on that wiki, and use that whenever the maps object isn't available.

Only when all of the other configurations are not set, should ProveIt assume the yyyy-mm-dd format.

But all this super functionality, while not super ultra difficult to implement, seems to me as rather low priority.