@@ -10,21 +10,21 @@ import { accessor as get } from './accessors';
10
10
// }
11
11
12
12
export function eventSegments ( event , first , last , { startAccessor, endAccessor, culture } ) {
13
- let startOfWeek = localizer . startOfWeek ( culture ) ;
14
- let start = dates . duration ( first , dates . max ( get ( event , startAccessor ) , first ) , 'weekday' , startOfWeek ) ;
13
+ let slots = dates . diff ( first , last , 'day' )
14
+ let start = dates . max ( get ( event , startAccessor ) , first ) ;
15
+ let end = dates . min ( get ( event , endAccessor ) , dates . add ( last , 1 , 'day' ) )
15
16
16
- let span = Math . min ( dates . duration (
17
- dates . max ( get ( event , startAccessor ) , first )
18
- , dates . min ( get ( event , endAccessor ) , dates . add ( last , 1 , 'day' ) )
19
- , 'day' ) , 7 ) ;
17
+ let span = dates . diff ( start , end , 'day' ) ;
20
18
21
- span = Math . max ( span , 1 ) ;
19
+ span = Math . min ( Math . max ( span , 1 ) , slots ) ;
20
+
21
+ let padding = dates . diff ( first , start , 'day' ) ;
22
22
23
23
return {
24
24
event,
25
25
span,
26
- left : start + 1 ,
27
- right : Math . max ( start + span , 1 )
26
+ left : padding + 1 ,
27
+ right : Math . max ( padding + span , 1 )
28
28
}
29
29
}
30
30
0 commit comments