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

[Bug] time from start and end date ignored in lightweighted datetimepicker #2573

Closed
ramsestom opened this issue Oct 6, 2018 · 3 comments
Closed
Assignees
Milestone

Comments

@ramsestom
Copy link

Currently, when setting the StartDate or EndDate of a lightweighted datetime picker (i.e a DateTimeSpinner3D), the time of these dates boundaries are ignored.
For exemple, if the current date is Sat Oct 6 and it is 10:00 AM, and I set this current date as startDate, I can still pick Sat Oct 6 3:00 AM in the picker.
It would be nice if the DateTime picker could take into account both the time and the date of a date object provided as boundary for the picker (and not just the date)

@codenameone codenameone added this to the Version 6.0 milestone Oct 6, 2018
@shannah
Copy link
Collaborator

shannah commented Oct 18, 2018

This is problematic because the time spinner options are the same for every date. E.g. suppose you want StartDate=Jan. 1, 2019 8PM, EndDate=Jan 2, 2019 7AM. It sounds like your intention is for the user to only be able to choose times on or after 8PM on Jan 1, and on or before 7AM on Jan 2. However, that's not really feasible, since the time options are independent of the date options. They are generated at the time that the component is created. Changing the date in the date spinner doesn't affect the options in the time spinner, and making it do so presents some UX challenges.

One possibility might be to add separate methods for startHour and endHour, but this also adds some complexity. E.g. If we prevent the time spinner from representing any time, then some dates can't be represented in the widget. This edge case is more intrusive than for min/max dates because timezones might cause dates that originally could be represented, to no longer be representable.

Can you describe the use case?

@ramsestom
Copy link
Author

The use case is pretty simple. I want the user to be able to inform my app of the date and time he is expecting to leave a specific place. Since he can't stay in this place more than a given numbers of days, the minimumDate and maximumDate of the Picker should be restricted by the current date and time and the place entry date and time + this max number of days respectively.
Same thing if I want a picker for the start date of a reservation period. The minimumDate should be restricted by the current date (as it doesn't make sense to make a reservation in the past). And I can also be interested into fixing a maximumDate (for example if you can't make a reservation more than one month in advance).
I think there are many use case where you need to be able to fix a minimumDate and maximumDate for a datetimepicker and in these case, you generally want to take into account the time of this bounds (else you would probably only use a DatePicker as, if you are not interested into the time of your picker bounds, there is a great chance that you don't care about the time for the value returned by your picker either)
How is the native iOS UIDatePicker (https://developer.apple.com/documentation/uikit/uidatepicker) handeling the case when you set minimumDate and maximumDate? (I don't have an iOS device at hand to test). I assume that if you spin to a date that is equal to the minimumDate and have the time part of the spinner with a time that is anterior to the time of this minimumDate, it automatically rolls back to the minimum time for this date. No? If yes, I think the CN1 lightweighted component should have the same behaviour as it is supposed to mimic it.

@shannah
Copy link
Collaborator

shannah commented Oct 19, 2018

I have added setStartDate(), setEndDate(), and setHourRange() methods to Picker so that you an now control the start/end dates/times. Check the javadocs because there are certain stipulations and edge cases you need to be aware of. E.g. They only have effect in lightweight mode. start/end dates have no effect on the time (hour/minutes). Etc...

Will be part of next update.

@shannah shannah closed this as completed Oct 19, 2018
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

No branches or pull requests

2 participants