Browse Source

Avoiding truncation in the menubar.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
2f807c2f5a
  1. 4
      Clocker/Dependencies/Date Additions/Date+TimeAgo.swift
  2. 4
      Clocker/Events and Reminders/CalendarHandler.swift

4
Clocker/Dependencies/Date Additions/Date+TimeAgo.swift

@ -115,10 +115,10 @@ public extension Date {
return DateToolsLocalizedStrings("An hour ago") return DateToolsLocalizedStrings("An hour ago")
} else if components.minute! >= 2 { } else if components.minute! >= 2 {
return logicalLocalizedStringFromFormat(format: "%%d %@minutes ago", value: components.minute!) return logicalLocalizedStringFromFormat(format: "%%d%@m ago", value: components.minute!)
} else if components.minute! >= 1 { } else if components.minute! >= 1 {
if numericTimes { if numericTimes {
return DateToolsLocalizedStrings("1 minute ago") return DateToolsLocalizedStrings("1m ago")
} }
return DateToolsLocalizedStrings("A minute ago") return DateToolsLocalizedStrings("A minute ago")

4
Clocker/Events and Reminders/CalendarHandler.swift

@ -493,12 +493,12 @@ struct EventInfo {
if timeIntervalSinceNowForMeeting < 0, timeIntervalSinceNowForMeeting > -300 { if timeIntervalSinceNowForMeeting < 0, timeIntervalSinceNowForMeeting > -300 {
return "started \(event.startDate.shortTimeAgoSinceNow) ago." return "started \(event.startDate.shortTimeAgoSinceNow) ago."
} else if event.startDate.isToday { } else if event.startDate.isToday {
let timeSince = Date().timeAgo(since: event.startDate) let timeSince = Date().timeAgo(since: event.startDate).lowercased()
let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString) let withoutAn = timeSince.replacingOccurrences(of: "an", with: CLEmptyString)
let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString) let withoutAgo = withoutAn.replacingOccurrences(of: "ago", with: CLEmptyString)
// If the user has not turned on seconds granularity for one of the timezones, // If the user has not turned on seconds granularity for one of the timezones,
// we return "in 12 seconds" which looks weird. // we return "in 12 seconds" which looks weird.
return withoutAgo.contains("seconds") ? "starts soon" : "in \(withoutAgo.lowercased())" return withoutAgo.contains("seconds") ? "started" : "in \(withoutAgo.lowercased())"
} else if event.startDate.isTomorrow { } else if event.startDate.isTomorrow {
let hoursUntil = event.startDate.hoursUntil let hoursUntil = event.startDate.hoursUntil
return "in \(hoursUntil)h" return "in \(hoursUntil)h"

Loading…
Cancel
Save