Skip to main content

max / makenotwork

Route custom-pages dollars() through the canonical formatter The custom-pages host had a local dollars() reimplementing the cents->dollars arithmetic (a second source of truth). Route it through formatting::format_dollars_plain — identical "$X.XX" output, one source for the conversion. Removes an ad-hoc /100 the pricing-format seal exists to prevent. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author: Max Johnson <me@maxj.phd> · 2026-06-25 05:14 UTC
Commit: de163611f689c79c552dc3b6a7e130f4edba3dd1
Parent: e9ecf1b
1 file changed, +4 insertions, -2 deletions
@@ -423,8 +423,10 @@ fn item_price_label(item: &db::DbItem) -> String {
423 423 }
424 424
425 425 fn dollars(cents: i32) -> String {
426 - let cents = cents.max(0);
427 - format!("${}.{:02}", cents / 100, cents % 100)
426 + // Route through the canonical formatter so the cents→dollars arithmetic has a
427 + // single source of truth (Run 9). Clamp negatives to 0 — custom pages never
428 + // show a negative price.
429 + format!("${}", crate::formatting::format_dollars_plain(cents.max(0)))
428 430 }
429 431
430 432 /// Bare hostname from the Host header, lowercased, port stripped.