Merge branch 'dt-format-t'

Add forgotten support for %T to our own wxDateTime::Format() code.

See #26180.
This commit is contained in:
Vadim Zeitlin
2026-02-11 13:51:26 +01:00
3 changed files with 11 additions and 1 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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]")