Skip to content

Commit 49e321f

Browse files
committed
[fixed] layout of events in months that don't start evenly at weekday 0
1 parent 720675e commit 49e321f

File tree

3 files changed

+25
-25
lines changed

3 files changed

+25
-25
lines changed

examples/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const Example = React.createClass({
3939
selectable
4040
popup
4141
events={events}
42-
defaultDate={new Date(2015, 1, 1)}
42+
defaultDate={new Date(2015, 3, 1)}
4343
eventPropGetter={e => ({ className: 'hi-event'})}
4444
components={{
4545
event: EventWeek,

examples/events.js

+20-20
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,52 @@ export default [
1212
{
1313
"title": "All Day Event",
1414
"allDay": true,
15-
"start": new Date(2015, 1, 1),
16-
"end": new Date(2015, 1, 1)
15+
"start": new Date(2015, 3, 0),
16+
"end": new Date(2015, 3, 0)
1717
},
1818
{
1919
"title": "Long Event",
20-
"start": new Date(2015, 1, 7),
21-
"end": new Date(2015, 1, 10),
20+
"start": new Date(2015, 3, 7),
21+
"end": new Date(2015, 3, 10),
2222
},
2323
{
2424
"title": "Some Event",
25-
"start": new Date(2015, 1, 9, 0, 0, 0),
26-
"end": new Date(2015, 1, 9, 0, 0, 0),
25+
"start": new Date(2015, 3, 9, 0, 0, 0),
26+
"end": new Date(2015, 3, 9, 0, 0, 0),
2727
},
2828
{
2929
"title": "Conference",
30-
"start": new Date(2015, 1, 11),
31-
"end": new Date(2015, 1, 13)
30+
"start": new Date(2015, 3, 11),
31+
"end": new Date(2015, 3, 13)
3232
},
3333
{
3434
"title": "Meeting",
35-
"start": new Date(2015, 1, 12, 10, 30, 0, 0),
36-
"end": new Date(2015, 1, 12, 12, 30, 0, 0)
35+
"start": new Date(2015, 3, 12, 10, 30, 0, 0),
36+
"end": new Date(2015, 3, 12, 12, 30, 0, 0)
3737
},
3838
{
3939
"title": "Lunch",
40-
"start":new Date(2015, 1, 12, 12, 0, 0, 0),
41-
"end": new Date(2015, 1, 12, 13, 0, 0, 0)
40+
"start":new Date(2015, 3, 12, 12, 0, 0, 0),
41+
"end": new Date(2015, 3, 12, 13, 0, 0, 0)
4242
},
4343
{
4444
"title": "Meeting",
45-
"start":new Date(2015, 1, 12,14, 0, 0, 0),
46-
"end": new Date(2015, 1, 12,15, 0, 0, 0)
45+
"start":new Date(2015, 3, 12,14, 0, 0, 0),
46+
"end": new Date(2015, 3, 12,15, 0, 0, 0)
4747
},
4848
{
4949
"title": "Happy Hour",
50-
"start":new Date(2015, 1, 12, 17, 0, 0, 0),
51-
"end": new Date(2015, 1, 12, 17, 30, 0, 0)
50+
"start":new Date(2015, 3, 12, 17, 0, 0, 0),
51+
"end": new Date(2015, 3, 12, 17, 30, 0, 0)
5252
},
5353
{
5454
"title": "Dinner",
55-
"start":new Date(2015, 1, 12, 20, 0, 0, 0),
56-
"end": new Date(2015, 1, 12, 21, 0, 0, 0)
55+
"start":new Date(2015, 3, 12, 20, 0, 0, 0),
56+
"end": new Date(2015, 3, 12, 21, 0, 0, 0)
5757
},
5858
{
5959
"title": "Birthday Party",
60-
"start":new Date(2015, 1, 13, 7, 0, 0),
61-
"end": new Date(2015, 1, 13, 10, 30, 0)
60+
"start":new Date(2015, 3, 13, 7, 0, 0),
61+
"end": new Date(2015, 3, 13, 10, 30, 0)
6262
}
6363
]

src/utils/eventLevels.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dates from './dates';
2+
import localizer from '../localizer';
23
import { accessor as get } from './accessors';
34
//import canUseDom from 'dom-helpers/util/inDOM';
45

@@ -8,10 +9,9 @@ import { accessor as get } from './accessors';
89
// isIE = ('documentMode' in document)
910
// }
1011

11-
export function eventSegments(event, first, last, { startAccessor, endAccessor }){
12-
13-
let start = dates.duration(first,
14-
dates.max(get(event, startAccessor), first), 'day');
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);
1515

1616
let span = Math.min(dates.duration(
1717
dates.max(get(event, startAccessor), first)

0 commit comments

Comments
 (0)