diff --git a/interface/wx/datetime.h b/interface/wx/datetime.h index 65a894519e..cb9495eb05 100644 --- a/interface/wx/datetime.h +++ b/interface/wx/datetime.h @@ -925,7 +925,9 @@ public: Notice that POSIX @c "%g", @c "%G", @c "%V" and @c "%z" format specifiers are supported even if the standard library doesn't support - them (e.g. MSVC). + them (as is the case when using MinGW, for example), but wxWidgets own + implementation is used if any of them are used instead of calling + `strftime()`. It also accepts a few wxWidgets-specific extensions: you can optionally specify the width of the field to follow using @c printf(3)-like syntax diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 9100dede38..ce8c97e329 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -634,6 +634,10 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const res += wxString::Format(fmt, tm.sec); break; + case wxT('T'): // time as %H:%M:%S + res += wxString::Format(wxT("%02d:%02d:%02d"), tm.hour, tm.min, tm.sec); + break; + case wxT('U'): // week number in the year (Sunday 1st week day) res += wxString::Format(fmt, GetWeekOfYear(Sunday_First, tz)); break; diff --git a/tests/datetime/datetimetest.cpp b/tests/datetime/datetimetest.cpp index b0ab1e28ae..13479f3ecd 100644 --- a/tests/datetime/datetimetest.cpp +++ b/tests/datetime/datetimetest.cpp @@ -796,6 +796,10 @@ TEST_CASE("wxDateTime::Format", "[datetime]") } CHECK(wxDateTime::Now().Format("%%") == "%"); + + + wxDateTime dt(29, wxDateTime::May, 1976, 18, 30, 15, 678); + CHECK( dt.Format("%F %T.%l") == "1976-05-29 18:30:15.678" ); } TEST_CASE("wxDateTime::ParseFormat", "[datetime]")