Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

Community realm. Read the code first. Community realm, deployed by its author. Read the code before you interact or send coins.

/p/nym-moultest123/x/daily/humanize/v1

Directory · 4 Files
README.md Open

gno.land/p/nym-moultest123/x/daily/humanize/v1

Human-facing number formatting — Bytes, Comma, Ordinal, Plural, Blocks, Truncate.

1import "gno.land/p/nym-moultest123/x/daily/humanize/v1"
2
3humanize.Bytes(1536)        // "1.5 KiB"
4humanize.Comma(1234567)     // "1,234,567"
5humanize.Ordinal(12)        // "12th"  — not "12nd"
6humanize.Plural(2, "mouse", "mice")  // "2 mice"
7humanize.Blocks(1234)       // "~1,200 blocks"
8humanize.Truncate("ééé", 2) // "é…"

v1 fixes Comma at the int64 minimum. v0 negated in int64, and -n on math.MinInt64 is math.MinInt64, so FormatInt emitted its own sign and the neg branch prepended a second: Comma(math.MinInt64) returned --9,223,372,036,854,775,808. The magnitude now goes through uint64. v0 stays resolvable for its existing importers.

Integer-only, on purpose. No floats anywhere: a rendered value that differed between nodes would be a consensus bug, so the single decimal place in Bytes comes from scaling by 10 and taking a remainder.

Durations are in blocks, never seconds. There is no wall clock on chain, so "about 2 hours" is a lie dressed as precision. Blocks says ~1,200 blocks and lets the caller decide what that means on their chain — and rounds deliberately, because false precision is worse than none.

Ordinal handles the teens (11th/12th/13th, not 11st/12nd/13rd) — the case naive implementations get wrong. Truncate counts runes, so multi-byte text is never sliced mid-character.

Live demo: r/moul/x/daily/humanizedemo · render it at /r/nym-moultest123/x/daily/humanizedemo/v0.


Part of moul/gno-contracts — moul's versioned gno.land contracts. See the repository for the full catalog, build/test tooling, and usage.

🧪 Highly experimental — potentially vibe-coded. Not audited; may break, change, or be removed at any time. Do not use with anything of value. Full disclaimer: DISCLAIMER.