import { VcalVeventComponent } from 'proton-shared/lib/interfaces/calendar/VcalModel' ; import { getDateOrDateTimeProperty } from 'proton-shared/lib/calendar/vcalConverter' ; import { getHasDtend , getIsPropertyAllDay } from 'proton-shared/lib/calendar/vcalHelper' ; import { addDays } from 'proton-shared/lib/date-fns-utc' ; import { CalendarEventRecurring } from '../../../interfaces/CalendarEvents' ; const withOccurrenceEvent = ( vevent , recurring ) : VcalVeventComponent => { const withOccurrenceDtstart = getDateOrDateTimeProperty ( vevent . dtstart , recurring . localStart ) ; if ( ! getHasDtend ( vevent ) ) { return { ... vevent , dtstart : withOccurrenceDtstart } ; } const safeEnd = getIsPropertyAllDay ( vevent . dtend ) ? addDays ( recurring . localEnd , 1 ) : recurring . localEnd ; return { ... vevent , dtstart : withOccurrenceDtstart , dtend : getDateOrDateTimeProperty ( vevent . dtend , safeEnd ) , } ; } ; export default withOccurrenceEvent ;