-
-
Notifications
You must be signed in to change notification settings - Fork 69
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 support for step
prop
#70
Comments
I think that's an excellent idea. Things to consider:
|
Hi everyone, Does anyone know what is the status with this? |
Definitely NOT a full solution but if you were so inclined you could simply hide the elements you didn't want. For instance I wanted to display only minutes divisible by 5 so I used the following scss to accomplish this
|
In case anyone else comes across this, my hacky solution was to intercept the change event, check how many minutes difference there is from the previous datetime, and then add/subtract the desired step before updating the value in state. I'm already using dayjs though so the date manipulations are easier. Hope this helps someone! const Container = () => {
const [datetime, setDatetime] = useState<Date>(new Date())
const handleChange = (newDatetime: Date) => {
const oldTime = dayjs.utc(datetime)
const newTime = dayjs.utc(newDatetime)
const diff = newTime.diff(oldTime, 'minutes')
if (diff === 1) {
const updatedNewTime = oldTime.add(30, 'minutes').toDate()
setDatetime(updatedNewTime)
} else if (diff === -1) {
const updatedNewTime = oldTime.subtract(30, 'minutes').toDate()
setDatetime(updatedNewTime)
} else {
setDatetime(newDatetime)
}
}
return (
<DateTimePicker
onChange={handleChange}
value={datetime}
/>
)
} |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
This is a simple proposal, when using this plugin, I came across a need to only make users input minutes that are round figures. Say, "12:00, 12:10, 12:20" because I needed to write a scheduler to check for the submitted dates on the backend and do something with it and I did not want to make it query the database every minute as it might consume resources, I felt making it check every 10 minutes would be better.
What I'm saying in essence is that maybe a feature should be added to allow developers customize the steps or multiples of minutes that can be selected.
The text was updated successfully, but these errors were encountered: