Commit 514fa801 authored by domenicw's avatar domenicw
Browse files

Small model changes

parent 0feadc67
......@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
B048377E21582D4E00AFA689 /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = B048377D21582D4E00AFA689 /* String+Extension.swift */; };
B050E120215169230090CB79 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = B050E11F215169230090CB79 /* AppDelegate.swift */; };
B050E127215169250090CB79 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B050E126215169250090CB79 /* Assets.xcassets */; };
B050E12A215169250090CB79 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = B050E128215169250090CB79 /* LaunchScreen.storyboard */; };
......@@ -91,6 +92,7 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
B048377D21582D4E00AFA689 /* String+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Extension.swift"; sourceTree = "<group>"; };
B050E11C215169230090CB79 /* Amiv.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Amiv.app; sourceTree = BUILT_PRODUCTS_DIR; };
B050E11F215169230090CB79 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
B050E126215169250090CB79 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
......@@ -188,6 +190,14 @@
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
B048377A21582C4500AFA689 /* Events */ = {
isa = PBXGroup;
children = (
B050E15821516E230090CB79 /* EventViewModel.swift */,
);
path = Events;
sourceTree = "<group>";
};
B050E113215169230090CB79 = {
isa = PBXGroup;
children = (
......@@ -337,8 +347,8 @@
B050E15721516E160090CB79 /* Model */ = {
isa = PBXGroup;
children = (
B048377A21582C4500AFA689 /* Events */,
B050E1882151A4850090CB79 /* Settings Model */,
B050E15821516E230090CB79 /* EventViewModel.swift */,
);
path = Model;
sourceTree = "<group>";
......@@ -358,6 +368,7 @@
B050E17E215195B50090CB79 /* UIFont+Extension.swift */,
B050E1932151A9750090CB79 /* Bundle+Extension.swift */,
B0D3F92A21552E8E005209FF /* UIButton+Extension.swift */,
B048377D21582D4E00AFA689 /* String+Extension.swift */,
);
path = Extension;
sourceTree = "<group>";
......@@ -794,6 +805,7 @@
B050E144215169950090CB79 /* Navigator.swift in Sources */,
B050E17A215180D20090CB79 /* AmivApplicationCell.swift in Sources */,
B07A8A0B21524474003CC2D8 /* LoginModel.swift in Sources */,
B048377E21582D4E00AFA689 /* String+Extension.swift in Sources */,
B0AF91382157B632008F3B80 /* JSONParameterEncoder.swift in Sources */,
B0FE2F1F21552AF700F3D073 /* KeychainSwiftConstants.swift in Sources */,
B050E15F2151735A0090CB79 /* UIColor+Extension.swift in Sources */,
......
//
// String+Extension.swift
// Amiv
//
// Created by Domenic Wüthrich on 23.09.18.
// Copyright © 2018 Amiv an der ETH. All rights reserved.
//
import Foundation
public extension String {
public func toDate() -> Date? {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZ"
formatter.locale = Locale.current
return formatter.date(from: self)
}
}
......@@ -13,8 +13,8 @@ public struct EventItem {
public let title: String
public let catchPhrase: String
public let location: String
public let startTime: String
public let endTime: String
public let startTime: Date
public let endTime: Date
public let description: String
......@@ -37,8 +37,19 @@ extension EventItem: Decodable {
self.title = try container.decode(String.self, forKey: .title)
self.catchPhrase = try container.decode(String.self, forKey: .catchPhrase)
self.location = try container.decode(String.self, forKey: .location)
self.startTime = try container.decode(String.self, forKey: .startTime)
self.endTime = try container.decode(String.self, forKey: .endTime)
if let startTime = try container.decode(String.self, forKey: .startTime).toDate() {
self.startTime = startTime
} else {
throw DecodingError.dataCorrupted(.init(codingPath: [EventItemResponseCodingKeys.startTime], debugDescription: "Invalid date string"))
}
if let endTime = try container.decode(String.self, forKey: .endTime).toDate() {
self.endTime = endTime
} else {
throw DecodingError.dataCorrupted(.init(codingPath: [EventItemResponseCodingKeys.endTime], debugDescription: "Invalid date string"))
}
self.description = try container.decode(String.self, forKey: .description)
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment