bunch of random work
This commit is contained in:
@@ -50,7 +50,7 @@ struct SettingsView: View {
|
||||
if useCloudKit {
|
||||
cloudKitStatus
|
||||
}
|
||||
|
||||
fixWeekday
|
||||
exportData
|
||||
importData
|
||||
Divider()
|
||||
@@ -96,6 +96,7 @@ struct SettingsView: View {
|
||||
if selectedFile.startAccessingSecurityScopedResource() {
|
||||
let dateFormatter = DateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss +0000"
|
||||
dateFormatter.timeZone = TimeZone(abbreviation: "UTC")
|
||||
|
||||
guard let input = String(data: try Data(contentsOf: selectedFile), encoding: .utf8) else { return }
|
||||
defer { selectedFile.stopAccessingSecurityScopedResource() }
|
||||
@@ -114,7 +115,10 @@ struct SettingsView: View {
|
||||
moodEntry.forDate = dateFormatter.date(from: columns[3])
|
||||
moodEntry.moodValue = Int16(columns[4])!
|
||||
moodEntry.timestamp = dateFormatter.date(from: columns[5])
|
||||
moodEntry.weekDay = Int16(columns[6])!
|
||||
|
||||
let localTime = dateFormatter.date(from: columns[3])!.toLocalTime()
|
||||
moodEntry.weekDay = Int16(Calendar.current.component(.weekday, from: localTime))
|
||||
|
||||
try! PersistenceController.shared.viewContext.save()
|
||||
}
|
||||
PersistenceController.shared.saveAndRunDataListerners()
|
||||
@@ -208,6 +212,21 @@ struct SettingsView: View {
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var fixWeekday: some View {
|
||||
ZStack {
|
||||
theme.currentTheme.secondaryBGColor
|
||||
Button(action: {
|
||||
PersistenceController.shared.fixWrongWeekdays()
|
||||
}, label: {
|
||||
Text("Fix Weekday")
|
||||
.foregroundColor(textColor)
|
||||
})
|
||||
.padding()
|
||||
}
|
||||
.fixedSize(horizontal: false, vertical: true)
|
||||
.cornerRadius(Constants.viewsCornerRaidus, corners: [.topLeft, .topRight, .bottomLeft, .bottomRight])
|
||||
}
|
||||
|
||||
private var whyBackgroundMode: some View {
|
||||
ZStack {
|
||||
theme.currentTheme.secondaryBGColor
|
||||
|
||||
Reference in New Issue
Block a user