]> git.ipfire.org Git - thirdparty/wireguard-apple.git/commitdiff
iOS: Use shorter pretty time
authorRoopesh Chander <roop@roopc.net>
Thu, 7 Feb 2019 22:44:10 +0000 (04:14 +0530)
committerRoopesh Chander <roop@roopc.net>
Thu, 7 Feb 2019 23:10:11 +0000 (04:40 +0530)
Signed-off-by: Roopesh Chander <roop@roopc.net>
WireGuard/WireGuard/Base.lproj/Localizable.strings
WireGuard/WireGuard/UI/TunnelViewModel.swift

index b92336095f313dff6882d9f75f3749aaf3050f4d..73cf50d609604b4fa996c226b0246656e4027ec9 100644 (file)
 "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 */
index 39d55bedc9793ea08b7442424fd5043ad359a0db..5de6cabea6575059adad886d869e534dc0028f1e 100644 (file)
@@ -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
 }