DamusDuration.swift (1568B)
1 // 2 // DamusDuration.swift 3 // damus 4 // 5 // Created by Charlie Fish on 1/13/24. 6 // 7 8 import Foundation 9 10 enum DamusDuration: CaseIterable { 11 case indefinite 12 case day 13 case week 14 case month 15 16 var title: String { 17 switch self { 18 case .indefinite: 19 return NSLocalizedString("Indefinite", comment: "Mute a given item indefinitly (until user unmutes it). As opposed to muting the item for a given period of time.") 20 case .day: 21 return NSLocalizedString("24 hours", comment: "A duration of 24 hours/1 day to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.") 22 case .week: 23 return NSLocalizedString("1 week", comment: "A duration of 1 week to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.") 24 case .month: 25 return NSLocalizedString("1 month", comment: "A duration of 1 month to be shown to the user. Most likely in the context of how long they want to mute a piece of content for.") 26 } 27 } 28 29 var date_from_now: Date? { 30 let current_date = Date() 31 32 switch self { 33 case .indefinite: 34 return nil 35 case .day: 36 return Calendar.current.date(byAdding: .day, value: 1, to: current_date) 37 case .week: 38 return Calendar.current.date(byAdding: .day, value: 7, to: current_date) 39 case .month: 40 return Calendar.current.date(byAdding: .month, value: 1, to: current_date) 41 } 42 } 43 }