Closed sffc closed 5 years ago
Why would abbreviations (of words they're not familiar with) be more friendly to non-English speakers?
I try to find an international standard which define "jan" or "mon" as code but I cannot find one. If you find one, we can refer to use that.
so... if you want it to be shorter, then why not su, mo, tu, we, th, fr, sa, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12?
ISO 8601 section 4.2.2 (Table 2) defines "Ordinal day number in the week" starting with Monday = 1. I hunted around but couldn't find another spec defining identifiers for month and day names.
However, we are a standards body too, so we are setting the new precedent. If no one has defined identifiers for weekday and month names, we can be the first to do so.
This only affects type "dateTime". The keys for dateTimeField come from formatToParts, and all other types have well-defined identifier syntax for the .of()
method.
If we wanted to avoid this question, we could so something like,
let names = new Intl.DisplayNames("en-US", { type: "weekday" });
console.log(names.of(1)); // "Monday"
for both weekdays and month names. That also fixes #46, which is basically looking for a pattern to get a list of weekday names or month names in a loop. Now you can do,
let names = new Intl.DisplayNames("en-US", { type: "weekday" });
// Written using a for loop for clarity
// You could use Array.prototype.map syntax here
let weekDayNames = [];
for (let i=1; i<=7; i++) {
weekDayNames.push(names.of(i));
}
Note: under the dateTime type, you have 4 categories: weekday, month, quarter, and dayPeriod. If we went with something like in this post, we can use those same strings as the type parameter.
I like the idea of breaking "dateTime" to 4 different types "weekday", "month", "quarter" and "dayPeriod". Let me propose a PR for this.
This is implemented in #49. However, the question about whether to use numbers or strings for the dayPeriod type is still an open question. @eemeli
Close this issue. Will open a different issue for the dayPeriod "am" / "pm"
The codes are
"monday"
,"tuesday"
, ...,"january"
,"february"
, ...Those are long and easy to make typos. They are maybe also not as friendly to non-English speakers. Did you consider shortening them to their common 3-letter abbreviations?
Weekdays:
Months: