@@ -9,23 +9,40 @@ import {
9
9
TouchableOpacity ,
10
10
Button
11
11
} from 'react-native' ;
12
- import XDate from 'xdate' ;
13
12
import { ExpandableCalendar , AgendaList , CalendarProvider } from 'react-native-calendars' ;
14
13
15
14
16
- const today = XDate ( ) . toString ( 'yyyy-MM-dd' ) ;
15
+ const today = new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
16
+ const fastDate = getPastDate ( 3 ) ;
17
+ const futureDates = getFutureDates ( 9 ) ;
18
+ const dates = [ fastDate , today ] . concat ( futureDates ) ;
19
+
20
+ function getFutureDates ( days ) {
21
+ const array = [ ] ;
22
+ for ( let index = 1 ; index <= days ; index ++ ) {
23
+ const date = new Date ( Date . now ( ) + ( 864e5 * index ) ) ; // 864e5 == 86400000 == 24*60*60*1000
24
+ const dateString = date . toISOString ( ) . split ( 'T' ) [ 0 ] ;
25
+ array . push ( dateString ) ;
26
+ }
27
+ return array ;
28
+ }
29
+
30
+ function getPastDate ( days ) {
31
+ return new Date ( Date . now ( ) - ( 864e5 * days ) ) . toISOString ( ) . split ( 'T' ) [ 0 ] ; // 864e5 == 86400000 == 24*60*60*1000
32
+ }
33
+
17
34
const items = [
18
- { title : '2019-05-27' , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
19
- { title : today , data : [ { hour : '4pm' , duration : '1h' , title : 'Pilates ABC' } , { hour : '5pm' , duration : '1h' , title : 'Vinyasa Yoga' } ] } ,
20
- { title : '2019-06-01' , data : [ { hour : '1pm' , duration : '1h' , title : 'Ashtanga Yoga' } , { hour : '2pm' , duration : '1h' , title : 'Deep Streches' } , { hour : '3pm' , duration : '1h' , title : 'Private Yoga' } ] } ,
21
- { title : '2019-06-02' , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
22
- { title : '2019-06-03' , data : [ { } ] } ,
23
- { title : '2019-06-04' , data : [ { hour : '9pm' , duration : '1h' , title : 'Pilates Reformer' } , { hour : '10pm' , duration : '1h' , title : 'Ashtanga' } , { hour : '11pm' , duration : '1h' , title : 'TRX' } , { hour : '12pm' , duration : '1h' , title : 'Running Group' } ] } ,
24
- { title : '2019-06-05' , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
25
- { title : '2019-06-06' , data : [ { } ] } ,
26
- { title : '2019-06-07' , data : [ { hour : '9pm' , duration : '1h' , title : 'Pilates Reformer' } , { hour : '10pm' , duration : '1h' , title : 'Ashtanga' } , { hour : '11pm' , duration : '1h' , title : 'TRX' } , { hour : '12pm' , duration : '1h' , title : 'Running Group' } ] } ,
27
- { title : '2019-06-08' , data : [ { hour : '1pm' , duration : '1h' , title : 'Ashtanga Yoga' } , { hour : '2pm' , duration : '1h' , title : 'Deep Streches' } , { hour : '3pm' , duration : '1h' , title : 'Private Yoga' } ] } ,
28
- { title : '2019-06-09' , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] }
35
+ { title : dates [ 0 ] , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
36
+ { title : dates [ 1 ] , data : [ { hour : '4pm' , duration : '1h' , title : 'Pilates ABC' } , { hour : '5pm' , duration : '1h' , title : 'Vinyasa Yoga' } ] } ,
37
+ { title : dates [ 2 ] , data : [ { hour : '1pm' , duration : '1h' , title : 'Ashtanga Yoga' } , { hour : '2pm' , duration : '1h' , title : 'Deep Streches' } , { hour : '3pm' , duration : '1h' , title : 'Private Yoga' } ] } ,
38
+ { title : dates [ 3 ] , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
39
+ { title : dates [ 4 ] , data : [ { } ] } ,
40
+ { title : dates [ 5 ] , data : [ { hour : '9pm' , duration : '1h' , title : 'Pilates Reformer' } , { hour : '10pm' , duration : '1h' , title : 'Ashtanga' } , { hour : '11pm' , duration : '1h' , title : 'TRX' } , { hour : '12pm' , duration : '1h' , title : 'Running Group' } ] } ,
41
+ { title : dates [ 6 ] , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
42
+ { title : dates [ 7 ] , data : [ { } ] } ,
43
+ { title : dates [ 8 ] , data : [ { hour : '9pm' , duration : '1h' , title : 'Pilates Reformer' } , { hour : '10pm' , duration : '1h' , title : 'Ashtanga' } , { hour : '11pm' , duration : '1h' , title : 'TRX' } , { hour : '12pm' , duration : '1h' , title : 'Running Group' } ] } ,
44
+ { title : dates [ 9 ] , data : [ { hour : '1pm' , duration : '1h' , title : 'Ashtanga Yoga' } , { hour : '2pm' , duration : '1h' , title : 'Deep Streches' } , { hour : '3pm' , duration : '1h' , title : 'Private Yoga' } ] } ,
45
+ { title : dates [ 10 ] , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] }
29
46
] ;
30
47
31
48
export default class ExpandableCalendarScreen extends Component {
0 commit comments