hour: "numeric" is shown as "2-digit" if paired with weekday but not month or year
See original GitHub issueThis seems to be a bug?
const format = {
weekday: 'long',
hour: 'numeric',
minute: '2-digit'
};
return dt.toLocaleString(format);
Expected output: 5:21 Actual output: 05:21
If month
or year
are added to the format object, or if weekday
is removed, hour
is correctly formatted as numeric
.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Date/Time Formats - IBM
This table lists the valid date and time formats. Format, Description. YYMMDD, Two-digit year, two-digit month, two-digit day.
Read more >SPSS Tutorials: Date-Time Variables in SPSS - LibGuides
In SPSS, date-time variables are treated as a special type of numeric variable. ... the order of the units (e.g. month-day-year versus year-month-day),...
Read more >User friendly date-time parsing functions - lubridate
Numeric values are the number of dates (in the training set) that matched the corresponding format. You should use this argument if the...
Read more >28 Working with dates | R for Epidemiology
By default, R will display dates in this format: 4-digit year, a dash, 2-digit month, a dash, and 2-digit day. For example, the...
Read more >DateTime Functions - Alteryx Help
The data must include at least a two-digit year. ... Returns an error only if the given text is not a name of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m also on a Mac. Doesn’t seem like it could be because of German, since yours also says “Wednesday”. But maybe it has something to do with it.
In any case, with German specified in the Intl constructor, I also get
Samstag, 05:21
, and I also see the dropped 0 if I remove the weekday.The Intl API spec is pretty complicated and has some allowances for the implementation to to make decisions based on combining the parameters you put in and the information it has about how the language works; it’s not as straightforward as it looks. However, I am not deeply familiar with the ins and outs, so I’m not sure whether it’s a bug in Chrome or not. Perhaps it is, in which case, a ticket with Chromium is needed.
But in any case, there’s nothing much Luxon can do about it. Luxon is just the messenger.
I have created a Chromium bug ticket here: https://bugs.chromium.org/p/chromium/issues/detail?id=1039138