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

fix(ui5-daterange-picker): working with format pattern containing the delimiter #2873

Merged

Conversation

tsanislavgatev
Copy link
Contributor

fixes: #2851

packages/main/src/DateRangePicker.js Outdated Show resolved Hide resolved
packages/main/src/DateRangePicker.js Outdated Show resolved Hide resolved
packages/main/src/DateRangePicker.js Outdated Show resolved Hide resolved
@unazko unazko self-requested a review March 2, 2021 09:02
@unazko
Copy link
Contributor

unazko commented Mar 2, 2021

Looks good to me.

if (this.getFormat().oFormatOptions.pattern.indexOf(this._effectiveDelimiter) >= 0) {
const midIndex = Math.round(value.length / 2);

valuesArray[0] = value.slice(0, midIndex).split(this._effectiveDelimiter).join("").trim();
Copy link
Contributor

Choose a reason for hiding this comment

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

.split(this._effectiveDelimiter).join("") -> this will remove all "-"s from the first part
same for the second part
Try running the function with "2020/01/01 - 2021/02/02" f.e.
You'll end up with "20200101" and "20210202" respectively.

IMO just get the mid index, everything from 0 to midIndex - 1 is the first part, and after mid index the second.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is done, because "2020/01/01 -" can't be formatted with our formatter, but 20200101 can. That's why i am removing the symbols that are breaking the formatting.

packages/main/src/DateRangePicker.js Outdated Show resolved Hide resolved
@vladitasev vladitasev merged commit b397862 into SAP:master Mar 12, 2021
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

Successfully merging this pull request may close these issues.

DateRangePicker failed to parse format "yyyy-MM-dd"
3 participants