question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hour: "numeric" is shown as "2-digit" if paired with weekday but not month or year

See original GitHub issue

This 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.

Example: https://codesandbox.io/s/eager-merkle-ixlr9

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
icambroncommented, Jan 5, 2020

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.

0reactions
fabyeahcommented, Jan 5, 2020

I have created a Chromium bug ticket here: https://bugs.chromium.org/p/chromium/issues/detail?id=1039138

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found