Time conversion functions with tests.

Fixes issue with incorrect characters in time strings on UI.
Fix platform dependency


Fix return value with incorrect strings.


Just use strptime and strftime on all platforms.

Emulate strptime on msvc... because they don't have it and their get_time is buggy.
This commit is contained in:
tamasmeszaros 2019-09-24 10:48:24 +02:00
parent f29e18dad2
commit d5dcba00b1
10 changed files with 296 additions and 99 deletions

View file

@ -35,9 +35,14 @@ static wxString generate_html_row(const Config::Snapshot &snapshot, bool row_eve
text += snapshot_active ? "#B3FFCB" : (row_even ? "#FFFFFF" : "#D5D5D5");
text += "\">";
text += "<td>";
static const constexpr char *LOCALE_TIME_FMT = "%x %X";
wxString datetime = wxDateTime(snapshot.time_captured).Format(LOCALE_TIME_FMT);
// Format the row header.
text += wxString("<font size=\"5\"><b>") + (snapshot_active ? _(L("Active")) + ": " : "") +
Utils::format_local_date_time(snapshot.time_captured) + ": " + format_reason(snapshot.reason);
text += wxString("<font size=\"5\"><b>") + (snapshot_active ? _(L("Active")) + ": " : "") +
datetime + ": " + format_reason(snapshot.reason);
if (! snapshot.comment.empty())
text += " (" + wxString::FromUTF8(snapshot.comment.data()) + ")";
text += "</b></font><br>";