aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard
diff options
context:
space:
mode:
authorRoopesh Chander <roop@roopc.net>2019-02-08 04:14:10 +0530
committerRoopesh Chander <roop@roopc.net>2019-02-08 04:40:11 +0530
commit1b8b9ed7ee10fb9c2d7a35a2d08f9b6edf834132 (patch)
tree0e670b58206680fe55608680bf0cae19e5e5a6a5 /WireGuard
parentiOS: Tunnel detail: Turn off animation when showing fields changing (diff)
downloadwireguard-apple-1b8b9ed7ee10fb9c2d7a35a2d08f9b6edf834132.tar.xz
wireguard-apple-1b8b9ed7ee10fb9c2d7a35a2d08f9b6edf834132.zip
iOS: Use shorter pretty time
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard')
-rw-r--r--WireGuard/WireGuard/Base.lproj/Localizable.strings3
-rw-r--r--WireGuard/WireGuard/UI/TunnelViewModel.swift19
2 files changed, 22 insertions, 0 deletions
diff --git a/WireGuard/WireGuard/Base.lproj/Localizable.strings b/WireGuard/WireGuard/Base.lproj/Localizable.strings
index b923360..73cf50d 100644
--- a/WireGuard/WireGuard/Base.lproj/Localizable.strings
+++ b/WireGuard/WireGuard/Base.lproj/Localizable.strings
@@ -108,6 +108,9 @@
"tunnelHandshakeTimestampSecond (%d)" = "%d second";
"tunnelHandshakeTimestampSeconds (%d)" = "%d seconds";
+"tunnelHandshakeTimestampHours hh:mm:ss (%@)" = "%@ hours";
+"tunnelHandshakeTimestampMinutes mm:ss (%@)" = "%@ minutes";
+
// Error alerts while creating / editing a tunnel configuration
/* Alert title for error in the interface data */
diff --git a/WireGuard/WireGuard/UI/TunnelViewModel.swift b/WireGuard/WireGuard/UI/TunnelViewModel.swift
index 39d55be..5de6cab 100644
--- a/WireGuard/WireGuard/UI/TunnelViewModel.swift
+++ b/WireGuard/WireGuard/UI/TunnelViewModel.swift
@@ -681,6 +681,24 @@ private func prettyTime(secondsLeft: Int64) -> String {
left = left % (60 * 60)
let minutes = left / 60
let seconds = left % 60
+
+ #if os(iOS)
+ if years > 0 {
+ return years == 1 ? tr(format: "tunnelHandshakeTimestampYear (%d)", years) : tr(format: "tunnelHandshakeTimestampYears (%d)", years)
+ }
+ if days > 0 {
+ return days == 1 ? tr(format: "tunnelHandshakeTimestampDay (%d)", days) : tr(format: "tunnelHandshakeTimestampDays (%d)", days)
+ }
+ if hours > 0 {
+ let hhmmss = String(format: "%02d:%02d:%02d", hours, minutes, seconds)
+ return tr(format: "tunnelHandshakeTimestampHours hh:mm:ss (%@)", hhmmss)
+ }
+ if minutes > 0 {
+ let mmss = String(format: "%02d:%02d", minutes, seconds)
+ return tr(format: "tunnelHandshakeTimestampMinutes mm:ss (%@)", mmss)
+ }
+ return seconds == 1 ? tr(format: "tunnelHandshakeTimestampSecond (%d)", seconds) : tr(format: "tunnelHandshakeTimestampSeconds (%d)", seconds)
+ #elseif os(macOS)
if years > 0 {
timeStrings.append(years == 1 ? tr(format: "tunnelHandshakeTimestampYear (%d)", years) : tr(format: "tunnelHandshakeTimestampYears (%d)", years))
}
@@ -697,4 +715,5 @@ private func prettyTime(secondsLeft: Int64) -> String {
timeStrings.append(seconds == 1 ? tr(format: "tunnelHandshakeTimestampSecond (%d)", seconds) : tr(format: "tunnelHandshakeTimestampSeconds (%d)", seconds))
}
return timeStrings.joined(separator: ", ")
+ #endif
}