36wxString toUsrDateTimeFormat(
const wxDateTime date_time,
38#
if wxCHECK_VERSION(3, 1, 6)
40 const wxUILocale& locale
43 wxDateTime t(date_time);
44 wxString effective_time_zone =
options.time_zone;
45 if (effective_time_zone == wxEmptyString) {
46 effective_time_zone = ::g_datetime_format;
48 if (effective_time_zone == wxEmptyString) {
49 effective_time_zone =
"UTC";
52 std::vector<std::pair<wxString, wxString>> formatMap = {
53#if wxCHECK_VERSION(3, 1, 6)
56 {
"$long_date_time", locale.GetInfo(wxLOCALE_LONG_DATE_FMT) +
" " +
57 locale.GetInfo(wxLOCALE_TIME_FMT)},
58 {
"$long_date", locale.GetInfo(wxLOCALE_LONG_DATE_FMT)},
59 {
"$weekday_short_date_time",
"%a " +
60 locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
61 " " + locale.GetInfo(wxLOCALE_TIME_FMT)},
62 {
"$weekday_short_date",
"%a " + locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
63 {
"short_date_time", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
" " +
64 locale.GetInfo(wxLOCALE_TIME_FMT)},
65 {
"$short_date", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
66 {
"$hour_minutes_seconds", locale.GetInfo(wxLOCALE_TIME_FMT)},
68 {
"$long_date_time",
"%x %X"},
71 {
"$weekday_short_date_time",
"%a %x %X"},
72 {
"$weekday_short_date",
"%a %x"},
73 {
"$short_date_time",
"%x %X"},
74 {
"$short_date",
"%x"},
75 {
"$hour_minutes_seconds",
"%X"},
77 {
"$hour_minutes",
"%H:%M"},
78 {
"$24_hour_minutes_seconds",
"%H:%M:%S"},
80 wxString format =
options.format_string;
81 if (format == wxEmptyString) {
82 format =
"$weekday_short_date_time";
86 for (
const auto& pair : formatMap) {
87 if (format.Contains(pair.first)) {
88 format.Replace(pair.first, pair.second);
93 format.Replace(wxString(wxUniChar(0x202F)),
" ");
96 if (effective_time_zone ==
"Local Time") {
97 wxDateTime now = wxDateTime::Now();
98 if ((now == (now.ToGMT())) &&
100 t.Add(wxTimeSpan(1, 0, 0, 0));
110 tzName = t.Format(
"%Z");
113 }
else if (effective_time_zone ==
"LMT") {
117 if (std::isnan(
options.longitude)) {
118 t = wxInvalidDateTime;
120 t.Add(wxTimeSpan(0, 0, wxLongLong(
options.longitude * 3600. / 15.)));
127 wxString formattedDate = t.Format(format);
129 return formattedDate +
" " + tzName;
131 return formattedDate;