Page MenuHomePhabricator

Change the date picker widget
Closed, DeclinedPublic3 Estimated Story Points

Description

Allow users to enter dates manually OR use the calendar widget to enter the date. TemplateWizard currently enforces use of the date picker to pick dates and inserts them in ISO format. The widget should be switched to be the one used by UploadWizard and Special:Block -

image.png (118×458 px, 13 KB)


While testing this extension with Template:Singles on the English Wikipedia, the form forced me to insert dates in ISO format because of parameters being classified as "date" in the template's TemplateData. I suspect that for various reasons there are approximately zero templates on the English Wikipedia where single-parameter dates should be entered in ISO format, even if it may be useful to do so on other wikis like the Chinese Wikipedia.

Even if this is a documentation error (I wrote the TemplateData for that template and I don't remember if date fields are always supposed to be ISO), the extension could be made locally configurable to allow users to enter any date instead.

Event Timeline

Restricted Application added subscribers: Stang, Aklapper. · View Herald Transcript
Niharika renamed this task from Date fields shouldn't force users to input ISO dates to Change the date picker widget.Nov 20 2018, 9:40 PM
Niharika triaged this task as Medium priority.
Niharika updated the task description. (Show Details)
Niharika set the point value for this task to 3.Nov 21 2018, 12:47 AM
Samwilson subscribed.

The TemplateData documentation says that date fields should be ISO8601. Like is mentioned above, I suspect that this is not a widespread assumption, but I've no idea what else is consuming date templatedata and relying on it being in the documented format.

I think if this is to change in TemplateWizard, it should first be clarified at the TemplateData side of things that this is an okay thing to do. I'm assuming it was made to be ISO8601 for some reason? (Or maybe not...)

It's worth noting that VisualEditor treats date-type fields as simple text boxes and you can enter whatever you like. I'm pretty sure we decided not to do that in TemplateWizard because if people want that sort of input they can just make these parameters 'text' format, and enter whatever they want.

The other thing I wonder about is which widget to actually use here, if we go ahead and change this. The UploadWizard and Special:Block date widgets are both specific to those places (uw.DateDetailsWidget and HTMLExpiryField respectively) and the former is only available where UploadWizard is and the latter has extra stuff that's not part of a generic 'date' input. Do we have to create a new input? Can it be part of the existing one (mw.widgets.DateInputWidget)?

The other possibility might be to extend TemplateData to have extra 'format' metadata and then feed any given date format into the current date widget (which supports different formats — and also 'precision' of day or month, but maybe that's getting too complicated).

@Samwilson As a practical matter, the assumption of ISO 8601 for dates is a design flaw in TemplateData, and as such a design flaw in TemplateWizard. I don't know how it was decided. For a new system it seems sensible, but I don't think anyone is going to be pushing for millions of dates (on hundreds of different projects) to be reformatted just so the software knows how to deal with them.

  • Because the English Wikipedia uses either DMY or MDY depending on the article, in the case of a single parameter accepting a date, it would be pointless to force users to include an extra parameter to indicate how a date should be formatted, rather than letting the template add the microformats and leave the text intact.
  • Partly because almost all of the English Wikipedia's templates were developed before the introduction of Scribunto in 2013, many of the templates which do accept ISO 8601 dates (e.g. {{Birth date}}) do so by receiving the year in the first parameter, the month in the second and the day in the third (|df=y indicates a DMY date; default is MDY). It would probably be considered extremely disruptive to change that now for no real benefit.
  • Also partly because of the late introduction of Scribunto, virtually all infobox templates (at least on the English Wikipedia) require the use of these helper templates and would not apply any formatting if a raw ISO 8601 date were used in their place.
  • Most dates do not need microformats in the first place, and citations cannot include microformats, so there would be little point in autoformatting such dates. What is entered is usually what is shown on the page.

As such, on the English Wikipedia, both the TemplateData feature and the TemplateWizard feature have virtually no practical utility in their current state, even if templates' TemplateData might indicate the date type. Because most other Wikipedias import templates from the English Wikipedia, almost every other Wikipedia's templates would not be able to make much use of those features.

I don't think you need a widget unless the widget is just three text boxes instead of one. There is no reason to use an interactive calendar if the user knows how dates work, and it makes data entry much slower. The constituency of Wikipedia editors who absolutely need to use the widget, or find it faster than entering ten characters, is probably very, very small.

it would be pointless to force users to include an extra parameter

Oh, sorry, I meant an extra parameter in the templatedata, e.g. { "type": "date", "dateformat": "DD/MM/YYYY" } (it could handle anything accepted by MomentJS I think).

I don't think you need a widget unless the widget is just three text boxes instead of one. There is no reason to use an interactive calendar if the user knows how dates work, and it makes data entry much slower. The constituency of Wikipedia editors who absolutely need to use the widget, or find it faster than entering ten characters, is probably very, very small.

So what is the benefit to having a date-type in templatedata at all? When would it be used? It sounds like dates for English Wikipedia at least would be better off just as text boxes, but they already can be by setting their type to 'text'. Or do you mean that this would make it easier than modifying the tempalatedata?

I meant an extra parameter in the templatedata

For clarity, I wasn't addressing this; I was commenting on the practicalities of using ISO 8601 dates in templates.

I think 'format' metadata could potentially be useful in general (not just for dates), but if the TemplateData is only going to be used within the edit window there might not be enough benefits to justify this sort of format checking. Even ignoring the considerable development time necessary, compared to the current ad-hoc-Module:String-and-tracking-category system it probably wouldn't be as flexible and might suffer from similar issues depending on implementation (e.g. like T157670), and compared to Wikidata's property constraints the available data could be less manageable. Asking the user adding the data to fix the data might be less efficient than the current system – the user might not understand what the error is due to the format being shown as a regular expression, for example. (Even for dates, you might also have to allow for different templates producing different microformats, multiple dates, other data being used in the same parameter, circa and floruit and BC/BCE, and so on.)

Something like property constraints – especially something that could automatically draw from Wikidata data based on link targets – would be an improvement on the current tracking system, although I think this would probably be most realistically achieved through a specialized Lua module written by one or a few community members, and you still wouldn't have enough editors going around fixing the errors.

So what is the benefit to having a date-type in templatedata at all? When would it be used?

If it's not useful as metadata, and it's not useful in the interface, I suppose it's pointless?

There are only 221 pages using the "date" type on the English Wikipedia, so I think it would actually be almost trivial to change those to the string type using AWB or a similar tool.

Mooeypoo subscribed.

This is an interesting discussion, but it's not quite for this product to make the decision. We read the spec off of TemplateData which allow template owners (and wikis) to set the templates the way they wish they behave for better behavior both on the wiki as well as while being edited by this tool or VisualEditor.

There might be wikis (or specific cases) where the ISO format or the 'date' parameter type are not suitable, but we -- as TemplateWizard product -- can't know or make that decision as a whole, so ignoring the parameter type or changing it wholesale isn't really something we can do.

I see that you've suggested changing a bulk of templates on English Wikipedia. I recommend that you take this conversation to the wiki for a community consensus and for action. As per this specific ticket, there's nothing we as TemplateWizard specifically can do, so I am closing this ticket.

Thank you for raising the issue!