feat(util): app-wide 24h/12h clock format

Add util::formatClockDateTime/formatClockTime driven by a process-wide flag (setClock12h,
synced from the time_format setting each frame). Switch the primary user-facing timestamp
displays to it — the transaction list, wallet-state tx + banned-peer times, the explorer
block time, and the block-info dialog — so one preference drives every clock.

Log files, export filenames/content, console line prefixes, the market chart axis, and the
worker-thread "last updated" string intentionally stay fixed 24h.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-17 18:44:44 -05:00
parent acde8c0833
commit 8d8cd337cf
6 changed files with 50 additions and 26 deletions

View File

@@ -14,6 +14,19 @@
namespace dragonx {
namespace util {
// App-wide clock format (24-hour vs 12-hour). Set once per frame by the App from the global
// `time_format` setting (setClock12h); the formatters below read it so a single preference drives
// every user-facing timestamp. The Chat tab resolves its own override separately.
void setClock12h(bool enabled);
bool clock12h();
// Format an epoch timestamp as a local wall-clock date+time honoring the app clock setting:
// 24h -> "YYYY-MM-DD HH:MM[:SS]", 12h -> "YYYY-MM-DD hh:MM[:SS] AM/PM". Empty when ts <= 0.
std::string formatClockDateTime(std::int64_t timestamp, bool withSeconds = false);
// Just the time-of-day portion honoring the clock setting: 24h "HH:MM[:SS]" / 12h "hh:MM[:SS] AM/PM".
std::string formatClockTime(std::int64_t timestamp, bool withSeconds = false);
// Localized relative time, e.g. "5 minutes ago" (via i18n). Empty when timestamp <= 0.
std::string formatTimeAgo(std::int64_t timestamp);