change a bunch of shit to get importing / adding new vote have the right weekday
This commit is contained in:
@@ -16,8 +16,7 @@ extension PersistenceController {
|
||||
})
|
||||
|
||||
data.forEach({
|
||||
$0.weekDay = Int16(Calendar.current.component(.weekday, from: $0.forDate!.startOfDay))
|
||||
$0.forDate = $0.forDate?.startOfDay
|
||||
$0.weekDay = Int16(Calendar.current.component(.weekday, from: $0.forDate!))
|
||||
})
|
||||
try? viewContext.save()
|
||||
}
|
||||
@@ -32,10 +31,7 @@ extension PersistenceController {
|
||||
newItem.timestamp = Date()
|
||||
newItem.moodValue = Int16(mood.rawValue)
|
||||
newItem.forDate = date
|
||||
|
||||
let localTime = date.toLocalTime()
|
||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: localTime))
|
||||
|
||||
newItem.weekDay = Int16(Calendar.current.component(.weekday, from: date))
|
||||
newItem.canEdit = true
|
||||
newItem.canDelete = true
|
||||
newItem.entryType = Int16(entryType.rawValue)
|
||||
@@ -47,7 +43,9 @@ extension PersistenceController {
|
||||
|
||||
func fillInMissingDates() {
|
||||
let currentOnboarding = UserDefaultsStore.getOnboarding()
|
||||
let endDate = ShowBasedOnVoteLogics.getLastDateVoteShouldExist(onboardingData: currentOnboarding)
|
||||
var endDate = ShowBasedOnVoteLogics.getCurrentVotingDate(onboardingData: currentOnboarding)
|
||||
// since its for views take away the last date so vote is enabled
|
||||
endDate = Calendar.current.date(byAdding: .day, value: -1, to: endDate)!
|
||||
|
||||
let fetchRequest = NSFetchRequest<MoodEntry>(entityName: "MoodEntry")
|
||||
fetchRequest.sortDescriptors = [NSSortDescriptor(key: "forDate", ascending: false)]
|
||||
|
||||
Reference in New Issue
Block a user