Unify labels, byte units, snapshot numbers and spelling

This commit is contained in:
Ian Gulliver
2026-10-23 10:33:47 -07:00
parent 68e0cc3063
commit eba85a6a1a
27 changed files with 54 additions and 65 deletions
+11
View File
@@ -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))
}