File tree 1 file changed +40
-0
lines changed 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { isWithinInterval } from "date-fns" ;
2
+
3
+ type DateInterval = {
4
+ tickets :{
5
+ startDay : string ,
6
+ endDay : string ,
7
+ } ,
8
+ cfp :{
9
+ startDay : string ,
10
+ endDay : string ,
11
+ } ,
12
+ sponsors :{
13
+ startDate : string ,
14
+ endDate : string ,
15
+ }
16
+ }
17
+
18
+ export const useDateInterval = ( today : Date , edition : DateInterval ) => {
19
+ const ticketStartDay = new Date ( edition . tickets . startDay ) ;
20
+ const ticketEndDay = new Date ( edition . tickets . endDay ) ;
21
+ const CFPStartDay = new Date ( edition . cfp . startDay ) ;
22
+ const CFPEndDay = new Date ( edition . cfp . endDay ) ;
23
+ const sponsorStartDay = new Date ( edition . sponsors . startDate ) ;
24
+ const sponsorEndDay = new Date ( edition . sponsors . endDate ) ;
25
+
26
+ return {
27
+ isTicketsDisabled : ! isWithinInterval ( today , {
28
+ start : ticketStartDay ,
29
+ end : ticketEndDay ,
30
+ } ) ,
31
+ isCfpDisabled : ! isWithinInterval ( today , {
32
+ start : CFPStartDay ,
33
+ end : CFPEndDay ,
34
+ } ) ,
35
+ isSponsorDisabled : ! isWithinInterval ( today , {
36
+ start : sponsorStartDay ,
37
+ end : sponsorEndDay ,
38
+ } ) ,
39
+ } ;
40
+ } ;
You can’t perform that action at this time.
0 commit comments