PathrockNetwork Gno Explorer
HomeBlocksTransactionsTokensRealmsPackagesValidatorsAnalytics

PathrockNetwork Gno Explorer — an independent explorer for Gno.land Mainnet (gnoland-1), operated by PathrockNetwork. Not an official Gno.land service.

gnowebarchive RPC

gno.land/p/moul/x/daily/humanize/v1

Package
Open in gnoweb ↗

Overview

Kind
Pure package
Name
v1
Namespace
moul / x / daily / humanize
Files
4 (README)(gnomod.toml)
Exported functions
n/a — not supported for pure packages by the node (vm/qfuncs)
Module
gno.land/p/moul/x/daily/humanize/v1
gno
0.9

Files (4)

  • README.mdmarkdown
  • gnomod.tomltoml
  • humanize.gnogno
  • humanize_test.gnogno
README.mdPreviewRaw
# `gno.land/p/moul/x/daily/humanize/v1`

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

```go
import "gno.land/p/moul/x/daily/humanize/v1"

humanize.Bytes(1536)        // "1.5 KiB"
humanize.Comma(1234567)     // "1,234,567"
humanize.Ordinal(12)        // "12th"  — not "12nd"
humanize.Plural(2, "mouse", "mice")  // "2 mice"
humanize.Blocks(1234)       // "~1,200 blocks"
humanize.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`](https://github.com/moul/gno-contracts/tree/main/r/moul/x/daily/humanizedemo)
· render it at [`/r/moul/x/daily/humanizedemo/v0`](https://gno.land/r/moul/x/daily/humanizedemo/v0).

<!-- BEGIN GNOCONTRACTS FOOTER (generated by `make readmes`; do not edit below) -->

---

Part of **[moul/gno-contracts](https://github.com/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](https://github.com/moul/gno-contracts/blob/main/DISCLAIMER.md).

<!-- END GNOCONTRACTS FOOTER -->

Functions

not supported for pure packages by the node (vm/qfuncs)

Signatures reconstructed verbatim from vm/qfuncs — interface params keep their inline definitions.