Skip to content

Commit

Permalink
Add example
Browse files Browse the repository at this point in the history
  • Loading branch information
saltire committed Sep 29, 2020
1 parent 4a1570f commit 7a909ca
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs-site/src/components/Examples/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import ShowTimeOnly from "../../examples/showTimeOnly";
import ExcludeTimes from "../../examples/excludeTimes";
import IncludeTimes from "../../examples/includeTimes";
import InjectTimes from "../../examples/injectTimes";
import FilterTimes from "../../examples/filterTimes";
import ExcludeTimePeriod from "../../examples/excludeTimePeriod";
import CustomDateFormat from "../../examples/customDateFormat";
import CustomClassName from "../../examples/customClassName";
Expand Down Expand Up @@ -195,6 +196,10 @@ export default class exampleComponents extends React.Component {
title: "Filter dates",
component: FilterDates
},
{
title: "Filter times",
component: FilterTimes
},
{
title: "Fixed height of Calendar",
component: FixedCalendar
Expand Down
1 change: 1 addition & 0 deletions docs-site/src/examples/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"useState": false,
"render": false,
"DatePicker": false,
"getHours": false,
"setHours": false,
"setMinutes": false,
"getDate": false,
Expand Down
18 changes: 18 additions & 0 deletions docs-site/src/examples/filterTimes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
() => {
const [startDate, setStartDate] = useState(
setHours(setMinutes(new Date(), 0), 9)
);
const from9to5 = time => {
const hour = getHours(time);
return hour >= 9 && hour < 17;
}
return (
<DatePicker
selected={startDate}
onChange={date => setStartDate(date)}
showTimeSelect
filterTime={from9to5}
dateFormat="MMMM d, yyyy h:mm aa"
/>
);
};

0 comments on commit 7a909ca

Please sign in to comment.