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

Expose value prop #9

Open
AviKKi opened this issue Nov 17, 2021 · 3 comments
Open

Expose value prop #9

AviKKi opened this issue Nov 17, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@AviKKi
Copy link

AviKKi commented Nov 17, 2021

Use Case -
When I want to show date range in format like "Nov 18, 22 - Nov 30, 22", I'm stuck default format is very verbose & does not offer best UI for most use cases.

Suggested solutions-

  1. expose value prop that can be passed to DtPicker, that will be further passed down to tag.
  2. expose a formatValue function, date or date range will be formatted using this function. Specifically this will requires passing correctValue function here as prop.

@mmehdinasiri Let me know your thoughts on this, I think we should go with 2. I'll do a PR after your approval.

PS: using this in production, so 🤞

Regards,
Atul Yadav

@mmehdinasiri
Copy link
Owner

Thank you for your suggestion,
Actually, I wanna implement a way to handle date formate in the future but right now I am busy a little until the next month but if you can help me I would be grateful.

@mmehdinasiri mmehdinasiri added the enhancement New feature or request label Nov 18, 2021
@AviKKi
Copy link
Author

AviKKi commented Nov 19, 2021

Cool I'll implement this feature then, using the 2nd proposed solution and raise a PR

AviKKi added a commit to AviKKi/react-calendar-datetime-picker that referenced this issue Nov 21, 2021
@AviKKi
Copy link
Author

AviKKi commented Nov 21, 2021

with above PR now you can add a formatValue prop to DtPicker component that will override the correctValue function's behaviour example below

const formatValue = ({ date }) => {
  if(date)  return (new Date(date.year, date.month, date.day)).toDateString()
  else return ''
}

time and type are also accessible in this prop function. @mmehdinasiri waiting for your approval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants