arqex / arqex/react-datetime

Time Constraints Cause Date Errors

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
2k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

# Time Constraints & Date Errors

I'm experiencing erroneous side effects for the date value when using the AM/PM buttons with custom time constraints.
## [Example on CodePen](http://codepen.io/baldwmic/pen/wzgRoz)

The date validation and time constraints are set up to restrict the date's value to future moments, but it appears there are some uncaught edge cases.

![react-datetime-bug](https://cloud.githubusercontent.com/assets/10538297/18770201/a21839f6-8101-11e6-9ed2-8de78803ca1d.gif)
Notice the value of the date is logged to the console when it changes.
### Note that
- 💚 When the date is `9/22` the `hour` button properly responds and cycles through the hours according to the time constraints without error.
- 🔴 When the date is `9/23`, clicking `up` on the `PM` button changes the the date again to the next `day` but does _not_ update the UI.
- 🔴 In fact, at this point, the `PM` button seems to be stuck and can not show `AM` even though the time constraints at this point should allow it.
## [Reproduce using CodePen](http://codepen.io/baldwmic/pen/wzgRoz)
### 🐛 1
1. Select the time picker and cycle through the `hours` to confirm works properly
2. Click either `up` or `down` arrow above or below the time period button (i.e `PM`), and confirm that an error exists where the date is improperly set! 😮
3. Keep clicking `up` or `down` and confirm that even though date shows another day with morning, the `AM` time period isn't shown, thus leading the UI to not reflect the actual date value 😢 .
### 🐛 2
1. Select a date in the future on the calendar.
2. Select the time picker and go to a time that is in the past for today's date. For example, if today is `Thursday, 10 PM`, select `Friday, 10 AM`.
3. Select today's date on the calendar. Note that the time is allowed even though it shouldn't be! 😢

---

Update: I [created a CodePen](http://codepen.io/baldwmic/pen/wzgRoz) to highlight the errors present when using time constraints.

---

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.