diff --git a/src/utils/TimeSlots.js b/src/utils/TimeSlots.js index 5374e22c2..d70e01475 100644 --- a/src/utils/TimeSlots.js +++ b/src/utils/TimeSlots.js @@ -11,14 +11,14 @@ const getKey = (min, max, step, slots) => export function getSlotMetrics({ min: start, max: end, step, timeslots }) { const key = getKey(start, end, step, timeslots) + // if the start is on a DST-changing day but *after* the moment of DST + // transition we need to add those extra minutes to our minutesFromMidnight + const daystart = dates.startOf(start, 'day') + const daystartdstoffset = getDstOffset(daystart, start) const totalMin = 1 + dates.diff(start, end, 'minutes') + getDstOffset(start, end) - const minutesFromMidnight = dates.diff( - dates.startOf(start, 'day'), - start, - 'minutes' - ) - + const minutesFromMidnight = + dates.diff(daystart, start, 'minutes') + daystartdstoffset const numGroups = Math.ceil(totalMin / (step * timeslots)) const numSlots = numGroups * timeslots diff --git a/stories/Durations.js b/stories/Durations.js index a6a06565d..f4f61f080 100644 --- a/stories/Durations.js +++ b/stories/Durations.js @@ -4,27 +4,100 @@ import moment from 'moment' import { Calendar, DragableCalendar } from './helpers' -storiesOf('Event Durations').add('Daylight savings', () => { - return ( - - ) -}) +storiesOf('Event Durations') + .add('Daylight savings starts', () => { + return ( + + ) + }) + .add('Daylight savings ends', () => { + return ( + + ) + }) + .add('Daylight savings starts, after 2am', () => { + return ( + + ) + }) + .add('Daylight savings ends, after 2am', () => { + return ( + + ) + })