Skip to content

add dateFormatter prop to dateTimePicker #1027

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

Merged
merged 5 commits into from
Nov 12, 2020

Conversation

lidord-wix
Copy link
Contributor

Description

Add dateFormatter prop to dateTimePicker

Changelog

Add dateFormatter prop to dateTimePicker

@lidord-wix lidord-wix requested a review from ethanshar November 10, 2020 12:05
@lidord-wix lidord-wix removed the request for review from ethanshar November 10, 2020 12:12
@ethanshar ethanshar requested a review from Inbal-Tish November 10, 2020 14:32
@ethanshar ethanshar assigned Inbal-Tish and unassigned ethanshar Nov 10, 2020
@lidord-wix lidord-wix requested review from ethanshar and removed request for Inbal-Tish November 10, 2020 14:37
@lidord-wix lidord-wix assigned ethanshar and unassigned Inbal-Tish Nov 10, 2020
if (value) {
if (dateFormatter && mode === MODES.DATE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would use a switch case here and include all logic in each case to make the code more readable. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed to switch case - not sure what is more readable..
Let me know if you have an idea for a better logic here :)

if (dateFormatter) {
return dateFormatter(value);
}
return dateFormat ? moment(value).format(dateFormat) : value.toLocaleDateString();
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can have all in one trinery:
return dateFormatter ? dateFormatter(value) : dateFormat ? moment(value).format(dateFormat) : value.toLocaleDateString();

@Inbal-Tish Inbal-Tish merged commit 9f516cd into master Nov 12, 2020
@lidord-wix lidord-wix deleted the feat/add_dateFormatter_prop_to_dateTimePicker branch December 15, 2020 07:50
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.

3 participants