cogentcore / core

A free and open source framework for building powerful, fast, elegant 2D and 3D apps that run on macOS, Windows, Linux, iOS, Android, and the web with a single Go codebase, allowing you to Code Once, Run Everywhere.
http://cogentcore.org/core
BSD 3-Clause "New" or "Revised" License
1.73k stars 82 forks source link

Add date format option #1138

Open kkoreilly opened 2 months ago

kkoreilly commented 2 months ago

Describe the feature

We should add a user setting for what date format to use (and maybe a field on TimeInput and DatePicker for controlling it as well). The default for the date format setting and the existing 24-hour clock setting should be set based on the locale as part of #9.

Relevant code

No response

theclapp commented 2 months ago

Does this mean, for example, that in the US the default would be month-day-year, but in the UK it would be day-month-year, or even year-month-day, or something like that?

kkoreilly commented 2 months ago

It is a very unfortunate situation, since it is impossible to fully avoid ambiguity given the US inconsistency, but we would probably try to comply with what each country uses as much as possible as stated here. This would mean MM/DD/YYYY in the US and DD/MM/YYYY in most other places by default.

The Material Design 2 date formats page doesn't really have clear guidance on what to do, although it seems they prefer the month to be spelled out with at least 3 letters where possible, which is clearer but not really possible for an input.

The Material Design 3 date picker accessibility guidelines recommend using the date format as the helper text, which I guess might get rid of any ambiguity:

The helper text (below the text field) should specify the date format (for example, MM/DD/YYYY or YYYY/MM/DD) and act as a description for the text field. The default helper text is "MM/DD/YYYY," but this can be customized.

Do you have any thoughts on what makes the most sense here?