-
Notifications
You must be signed in to change notification settings - Fork 734
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
add dateFormatter prop to dateTimePicker #1027
Conversation
if (value) { | ||
if (dateFormatter && mode === MODES.DATE) { |
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.
I would use a switch case here and include all logic in each case to make the code more readable. What do you think?
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.
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(); |
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.
You can have all in one trinery:
return dateFormatter ? dateFormatter(value) : dateFormat ? moment(value).format(dateFormat) : value.toLocaleDateString();
Description
Add dateFormatter prop to dateTimePicker
Changelog
Add dateFormatter prop to dateTimePicker