💄 Updating events list view

This commit is contained in:
2021-04-07 21:15:22 +02:00
committed by Patrick Müller
parent 06b66a50a5
commit f6e1d979fd
4 changed files with 146 additions and 39 deletions
+18
View File
@@ -0,0 +1,18 @@
//
// DateExtension.swift
// DHBW-Service
//
// Created by Patrick Müller on 07.04.21.
//
import Foundation
extension Date {
func get(_ components: Calendar.Component..., calendar: Calendar = Calendar.current) -> DateComponents {
return calendar.dateComponents(Set(components), from: self)
}
func get(_ component: Calendar.Component, calendar: Calendar = Calendar.current) -> Int {
return calendar.component(component, from: self)
}
}
+4 -2
View File
@@ -264,6 +264,8 @@ class RaPlaFetcher {
print("Found unknown frequency: " + event.frequency)
}
// (offsetAmount * iteration) because for the 1st event, we dont want to add an offset, and
// for every event after that we want to add e.g. 1 week, 2 weeks, 3 weeks etc.
let startDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.startDate)!
let endDate = Calendar.current.date(byAdding: offsetType, value: (offsetAmount * iteration), to: event.endDate)!
@@ -288,8 +290,6 @@ class RaPlaFetcher {
}
// Populate fields
// (offsetAmount * iteration) because for the 1st event, we dont want to add an offset, and
// for every event after that we want to add e.g. 1 week, 2 weeks, 3 weeks etc.
evt.startDate = startDate
evt.endDate = endDate
evt.summary = event.summary
@@ -298,6 +298,8 @@ class RaPlaFetcher {
evt.category = event.category
evt.uid = newUID
for lecturer in event.lecturers {
// TODO: Delete all old lecturer objects
let lect = Lecturer(context: PersistenceController.shared.context)
lect.name = lecturer.name
lect.email = lecturer.email