|
|
@@ -76,16 +76,19 @@ struct ContentView: View {
|
|
|
}
|
|
|
|
|
|
let ymd = weekStart.formatted(.iso8601.year().month().day())
|
|
|
+ save(to: URL.documentsDirectory.appending(path: "Todo \(ymd).yaml"))
|
|
|
+ weekStart = now
|
|
|
+ }
|
|
|
+
|
|
|
+ private func save(to: URL) {
|
|
|
let data = Data(items.map({ $0.yaml() }).joined().utf8)
|
|
|
- let url = URL.documentsDirectory.appending(path: "Todo \(ymd).yaml")
|
|
|
do {
|
|
|
- try data.write(to: url, options: [.atomic, .completeFileProtection])
|
|
|
- let input = try String(contentsOf: url, encoding: .utf8)
|
|
|
+ try data.write(to: to, options: [.atomic, .completeFileProtection])
|
|
|
+ let input = try String(contentsOf: to, encoding: .utf8)
|
|
|
print(input)
|
|
|
} catch {
|
|
|
print(error.localizedDescription)
|
|
|
}
|
|
|
- weekStart = now
|
|
|
}
|
|
|
|
|
|
private func deleteItem(item: Category) {
|