[O] Optimize Andrew's setData
This commit is contained in:
@@ -66,11 +66,11 @@ class AlarmTableCell: UITableViewCell
|
|||||||
func setData(_ alarm: Alarm)
|
func setData(_ alarm: Alarm)
|
||||||
{
|
{
|
||||||
descriptionText.text = "- " + alarm.text
|
descriptionText.text = "- " + alarm.text
|
||||||
|
|
||||||
|
// Display Hour, Minute, and AM or PM
|
||||||
ampm.text = alarm.hour < 12 || alarm.hour == 24 ? "AM" : "PM"
|
ampm.text = alarm.hour < 12 || alarm.hour == 24 ? "AM" : "PM"
|
||||||
if alarm.hour > 12{
|
let hour = alarm.hour <= 12 ? alarm.hour : alarm.hour - 12
|
||||||
alarm.hour -= 12
|
time.text = alarm.minute < 10 ? "\(hour):0\(alarm.minute)" : "\(hour):\(alarm.minute)"
|
||||||
}
|
|
||||||
time.text = alarm.minute<10 ? "\(alarm.hour)" + ":" + "0" + "\(alarm.minute)":"\(alarm.hour)" + ":" + "\(alarm.minute)"
|
|
||||||
|
|
||||||
// displays the specific days alarm is activated
|
// displays the specific days alarm is activated
|
||||||
let daysDict = [0: "Mon", 1: "Tues", 2: "Wed", 3: "Thurs", 4: "Fri", 5: "Sat", 6: "Sun"]
|
let daysDict = [0: "Mon", 1: "Tues", 2: "Wed", 3: "Thurs", 4: "Fri", 5: "Sat", 6: "Sun"]
|
||||||
@@ -84,6 +84,8 @@ class AlarmTableCell: UITableViewCell
|
|||||||
}
|
}
|
||||||
repeatText.text = daysActive.joined(separator: ", ")
|
repeatText.text = daysActive.joined(separator: ", ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Show next activation date
|
||||||
if alarm.enabled, let n = alarm.nextActivate {
|
if alarm.enabled, let n = alarm.nextActivate {
|
||||||
goingOffText.text = "(Going off in \(n.timeIntervalSince(Date()).str()))"
|
goingOffText.text = "(Going off in \(n.timeIntervalSince(Date()).str()))"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user