Files
Reflect/Shared/Random.swift
Trey t 0109aee8f8 switch db between debug and release
on widgets if its before the voting time show yesterdays vote, if after either show no vote or current vote

user shared user defaults
2022-01-28 10:27:33 -06:00

41 lines
1003 B
Swift

//
// Random.swift
// Feels
//
// Created by Trey Tartt on 1/9/22.
//
import Foundation
struct Constants {
static let groupShareId = "group.com.88oak.ifeel"
}
struct GroupUserDefaults {
static var groupDefaults: UserDefaults {
return UserDefaults(suiteName: Constants.groupShareId)!
}
}
class Random {
static var tomorrowMidnightThirty: Date {
let components = DateComponents(hour: 0, minute: 30, second: 0)
var updateTime = Date()
if let tomorrow = Calendar.current.date(byAdding: .day, value: 1, to: Date()),
let tomorrowMorning = Calendar.current.date(byAdding: components, to: tomorrow) {
updateTime = tomorrowMorning
}
return updateTime
}
}
extension Date: RawRepresentable {
public var rawValue: String {
self.timeIntervalSinceReferenceDate.description
}
public init?(rawValue: String) {
self = Date(timeIntervalSinceReferenceDate: Double(rawValue) ?? 0.0)
}
}