Skip to content

Commit

Permalink
improve TimeFilter for custom date (#463)
Browse files Browse the repository at this point in the history
* prevent invalid filter from being saved

* fix wrong date being used in custom date select

* set end date to 23 59 59

* remove showError

* indent

* lint fix

---------

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
  • Loading branch information
BBBmau and adeebshihadeh authored May 16, 2024
1 parent 590ebaa commit e85a82e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/components/AppHeader/TimeFilter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ class TimeSelect extends Component {
changeStart(event) {
if (event.target.valueAsDate) {
this.setState({
start: event.target.valueAsDate.setHours(0, 0, 0, 0),
start: new Date(event.target.valueAsDate.getUTCFullYear(), event.target.valueAsDate.getUTCMonth(), event.target.valueAsDate.getUTCDate()).getTime(),
});
}
}

changeEnd(event) {
if (event.target.valueAsDate) {
this.setState({
end: event.target.valueAsDate.setHours(23, 59, 59, 999),
end: new Date(event.target.valueAsDate.getUTCFullYear(), event.target.valueAsDate.getUTCMonth(), event.target.valueAsDate.getUTCDate(),23,59,59).getTime(),
});
}
}
Expand Down Expand Up @@ -215,7 +215,7 @@ class TimeSelect extends Component {
<input
label="End date"
type="date"
min={ minDate }
min={ startDate }
max={ maxDate }
onChange={this.changeEnd}
value={ endDate }
Expand Down

0 comments on commit e85a82e

Please sign in to comment.