Unify labels, byte units, snapshot numbers and spelling
This commit is contained in:
@@ -150,6 +150,17 @@ func ago(_ date: Date) -> String {
|
||||
return "\(seconds / 86400)d ago"
|
||||
}
|
||||
|
||||
func bytes(_ n: Int64) -> String {
|
||||
let units = ["B", "KiB", "MiB", "GiB", "TiB"]
|
||||
var i = 0
|
||||
var v = Double(n)
|
||||
while v >= 1024 && i < units.count - 1 {
|
||||
v /= 1024
|
||||
i += 1
|
||||
}
|
||||
return "\(v.formatted(.number.precision(.fractionLength(i == 0 ? 0 : 1)).grouping(.never))) \(units[i])"
|
||||
}
|
||||
|
||||
func isoText(_ date: Date) -> String {
|
||||
date.formatted(Date.ISO8601FormatStyle(includingFractionalSeconds: true))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user