-
Notifications
You must be signed in to change notification settings - Fork 278
feat(ui5-dynamic-date-range): introduce From/To (Date & Time) option #12341
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Preview deployment ready: https://UI5.github.io/webcomponents/pr-12341/ The preview will be updated automatically when you push new commits to this PR. |
🚀 Deployed on https://pr-12341--ui5-webcomponents-preview.netlify.app |
}; | ||
|
||
const dateTimeRangeOptionToDates = (value: DynamicDateRangeValue): Array<Date> => { | ||
const startDate = value.values ? value.values[0] as Date : UI5Date.getInstance(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor:
It took me a while to understand what does this actually do.
We can adjust it a little for readibility, like e.g. (havent tested it, just suggestion)
const [firstValue, secondValue] = value.values || [];
const currenDate = UI5Date.getInstance();
const startDate = firstValue instanceof Date ? firstValue : currentDate;
const endDate = secondValue instanceof Date ? secondValue : currentDate;
return [startDate, endDate];
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo both approaches read very similar to me, and considering all other toDates methods are formulated the same way, I'm leaving it as-is for now. If @tsanislavgatev has a strong preference for your suggestion, I can change it then.
With this PR we introduce a new "From/To (Date & Time)" option for the
ui5-dynamic-date-range
, allowing users to select a range of dates with times.Example:
Usage:
To add the option to your DynamicDateRange, add
DATETIMERANGE
in theoptions
attribute as follows:Related to: #12182