Skip to main content

Module format

Module format 

Source
Expand description

Pure cell formatting: numbers, dates, strings, booleans, filter matching.

All functions here are intentionally GPUI-free so they can be reused for exports, server-side previews, and tests. The widget layer calls format_cell on every visible cell during paint and on every clipboard-copy; tests below document the public behavior.

Functions§

alignment_for
cell_matches_filter
Case-insensitive substring filter against the user-visible rendered text. Empty filter always matches.
format_cell
Format any cell into the user-visible text plus a “is negative” flag that lets paint code color it red without re-parsing the text.
format_date
Format a Unix timestamp (seconds). When fmt.relative is set, the result is a “2 days ago” / “in 3 weeks” string relative to SystemTime::now(); use format_date_at to inject a frozen clock for tests.
format_date_at
Same as format_date but with an explicit now timestamp so tests can pin the relative-date output to a known clock.
format_integer
Format a CellValue::Integer against a NumberFormat without first casting through f64. This preserves full i64 precision for values larger than 2^53.
format_number
Format a f64 against a NumberFormat. Negative formatting (parentheses vs leading minus) and thousands separators are driven by the format options.
format_relative_date
format_string
Format text according to a StringFormat: case, length, truncation.