Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing hours using single digit without separator gives invalid results #2714

Open
teemuqvick opened this issue Aug 21, 2024 · 0 comments
Open

Comments

@teemuqvick
Copy link

Trying to parse single digit hours doesn't work correctly when there is no separator character:

dayjs("20240726 931", 'YYYYMMDD Hmm', true).isValid() // false, expected true
dayjs("931", 'Hmm', true).isValid() // false, expected true
dayjs("20240726 931", 'YYYYMMDD Hmm', true).hour() // 21, expected 9

If there is a separator between H and mm then result is as expected:

dayjs("20240726 9 31", 'YYYYMMDD H mm', true).isValid() // true, expected true
dayjs("9 31", 'H mm', true).isValid() // true, expected true
dayjs("9 31", 'H mm', true).hour() // 9, expected 9

Information

  • Day.js Version: v1.11.12
  • OS: Windows
  • Browser: Edge 127.0.2651.98
  • Time zone: UTC +3 EEST (Eastern European Summer Time)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant