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:
@@ -203,10 +203,7 @@ void BlockInfoDialog::render(App* app)
|
||||
ImGui::Text("%s", TR("block_timestamp"));
|
||||
ImGui::SameLine(lbl.position);
|
||||
if (s_block_time > 0) {
|
||||
std::time_t t = static_cast<std::time_t>(s_block_time);
|
||||
char time_buf[64];
|
||||
std::strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", std::localtime(&t));
|
||||
ImGui::Text("%s", time_buf);
|
||||
ImGui::Text("%s", dragonx::util::formatClockDateTime(s_block_time, /*withSeconds=*/true).c_str());
|
||||
} else {
|
||||
ImGui::TextDisabled("%s", TR("unknown"));
|
||||
}
|
||||
|
||||
@@ -1127,10 +1127,8 @@ static void renderBlockDetailModal(App* app) {
|
||||
// Row 1: Timestamp | Confirmations
|
||||
drawLabelValue(dl, gx, gy, labelW, TR("block_timestamp"), "", capFont, sub1);
|
||||
if (s_detail_time > 0) {
|
||||
std::time_t t = static_cast<std::time_t>(s_detail_time);
|
||||
char time_buf[64];
|
||||
std::strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", std::localtime(&t));
|
||||
dl->AddText(sub1, sub1->LegacySize, ImVec2(gx + labelW, gy), OnSurface(), time_buf);
|
||||
const std::string tstr = dragonx::util::formatClockDateTime(s_detail_time, /*withSeconds=*/true);
|
||||
dl->AddText(sub1, sub1->LegacySize, ImVec2(gx + labelW, gy), OnSurface(), tstr.c_str());
|
||||
}
|
||||
dl->AddText(capFont, capFont->LegacySize, ImVec2(gx + halfW, gy), OnSurfaceMedium(), TR("confirmations"));
|
||||
snprintf(buf, sizeof(buf), "%d", s_detail_confirmations);
|
||||
|
||||
@@ -64,10 +64,7 @@ struct DisplayTx {
|
||||
|
||||
std::string DisplayTx::getTimeString() const {
|
||||
if (timestamp <= 0) return TR("pending");
|
||||
std::time_t t = static_cast<std::time_t>(timestamp);
|
||||
char buf[64];
|
||||
std::strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M", std::localtime(&t));
|
||||
return buf;
|
||||
return dragonx::util::formatClockDateTime(timestamp); // honors the app-wide 24h/12h clock
|
||||
}
|
||||
|
||||
// Relative time string (localized long form, e.g. "5 minutes ago")
|
||||
|
||||
Reference in New Issue
Block a user