Lightweight text-formatting helpers.
Keep this module free of heavy dependencies so it can be imported anywhere in the app without pulling in large frameworks.
Format a duration in seconds into a human-readable string.
Read macOS's "24-Hour Time" preference (AppleICUForce24HourTime).
macOS exposes the clock style as a global preference that does not surface
through the POSIX LC_TIME locale (libc %X is 24-hour for every macOS
locale), so it must be read separately.
Whether the system is configured for a 24-hour clock.
On macOS the clock style lives in the AppleICUForce24HourTime system
preference rather than the POSIX locale, so that is consulted first (see
macos_force_24_hour_time). When that preference is unset we intentionally
default to a 24-hour clock: macOS resolves the region's 12-/24-hour default
via ICU/CFLocale, which POSIX cannot read (libc %X is 24-hour for every
macOS locale), so the locale probe below would be meaningless there.
On every other platform the active LC_TIME locale's time representation
is probed instead.
The result is cached because resolving it mutates process-global locale
state via locale.setlocale(locale.LC_TIME, "") (scoped to the time
category, and only ever performed once).
Format a message timestamp for display.
Shows only the time of day for messages from the current local date and
prefixes the date otherwise. The 12- versus 24-hour clock follows the
system configuration (see uses_24_hour_clock).