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

[Calendar] Chrome chooses wrong hour on time-only calendar #1569

Merged
merged 1 commit into from
Jul 12, 2020

Conversation

exoego
Copy link
Contributor

@exoego exoego commented Jul 12, 2020

Description

var textDate = new Date(text);
if(!isNaN(textDate.getDate())) {
return textDate;
}

The above code expects parsing on partial input, e.g. 1, to be failed on new Date("1").
However, there are incosintency between browsers on how new Date consturctor or Date.parse works.

input Chrome Firefox
new Date("1") success invalid
new Date("10") success invalid
new Date("100") success invalid
new Date("1000") success success

On Chrome, new Date("1") or such can create instance of Date.
So, getDate is a number, then hour is not chosen correctly.

This PR adds a check input is number-only `^[0-9]+$ or not.
If input is number-only, it should go to time-only or date-only logic.

Testcase

Broken (on Chrome)

https://jsfiddle.net/m8a4r3t9/

Fixed (on Chrome)

https://jsfiddle.net/9og37k1t/1/

Closes

#1354

@exoego exoego added type/bug Any issue which is a bug or PR which fixes a bug lang/javascript Anything involving JavaScript browser/chromium Any issues relating to Chromium (Chrome, Edge (new), Opera, Brave etc.) labels Jul 12, 2020
@exoego exoego removed the browser/chromium Any issues relating to Chromium (Chrome, Edge (new), Opera, Brave etc.) label Jul 12, 2020
Copy link
Member

@lubber-de lubber-de left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lubber-de lubber-de added this to the 2.8.7 milestone Jul 12, 2020
@lubber-de lubber-de added the state/awaiting-reviews Pull requests which are waiting for reviews label Jul 12, 2020
Copy link
Member

@ko2in ko2in left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@lubber-de lubber-de merged commit 2239f64 into fomantic:develop Jul 12, 2020
@lubber-de lubber-de removed the state/awaiting-reviews Pull requests which are waiting for reviews label Jul 12, 2020
@exoego exoego deleted the 1354-chrome-wrong-time branch July 12, 2020 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/javascript Anything involving JavaScript type/bug Any issue which is a bug or PR which fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants