humanize
Durations, byte sizes, relative times, ordinals and counted words for people to read. Pure - no capabilities. The std.humanize module, as a package.
ecko get github.com/ecko-lang/humanize
import humanize
Pure computation: it declares no capabilities, so it cannot touch the network, the filesystem or the environment.
Version 0.1.0 - source - MIT.
duration(ms)
The two largest non-zero units of a duration in milliseconds. duration(7505000) is "2h 5m", duration(3600000) is "1h", and anything under a second is milliseconds: duration(250) is "250ms". A negative duration renders as its magnitude.
size(bytes)
A byte count in 1024-based units with one decimal, trailing .0 dropped: size(1468006) is "1.4 MB", size(1024) is "1 KB", size(512) is "512 B". Units run B, KB, MB, GB, TB, PB.
relative(event, now)
Coarse relative time between two unix-millisecond timestamps: event, and now - pass time.now(). A later now reads as the past ("3 days ago"), an earlier one as the future ("in 2 hours"), and within five seconds either way is "just now". Units run seconds, minutes, hours, days, months (30 days) and years (365 days).
ordinal(n)
The English ordinal of a whole number: ordinal(1) is "1st", ordinal(11) is "11th", ordinal(23) is "23rd". A Float is truncated first.
plural(n, singular, plural = null)
A count and a word, the word pluralised for anything but 1 or -1: plural(3, "day") is "3 days". Pluralising only adds s; pass the plural for anything irregular: plural(2, "person", "people") is "2 people".