44wxString toUsrDateTimeFormat(
const wxDateTime date_time,
46#
if wxCHECK_VERSION(3, 1, 6)
48 const wxUILocale& locale
51 wxDateTime t(date_time);
52 wxString effective_time_zone =
options.time_zone;
53 if (effective_time_zone ==
"") {
56 if (effective_time_zone ==
"") {
57 effective_time_zone =
"UTC";
60 wxString aform = androidGetLocalizedDateTime(
options, date_time);
61 if (!aform.IsEmpty())
return aform;
65 std::vector<std::pair<wxString, wxString>> formatMap = {
66#if wxCHECK_VERSION(3, 1, 6)
69 {
"$long_date_time", locale.GetInfo(wxLOCALE_LONG_DATE_FMT) +
" " +
70 locale.GetInfo(wxLOCALE_TIME_FMT)},
71 {
"$long_date", locale.GetInfo(wxLOCALE_LONG_DATE_FMT)},
72 {
"$weekday_short_date_time",
"%a " +
73 locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
74 " " + locale.GetInfo(wxLOCALE_TIME_FMT)},
75 {
"$weekday_short_date",
"%a " + locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
76 {
"$short_date_time", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
" " +
77 locale.GetInfo(wxLOCALE_TIME_FMT)},
78 {
"$short_date", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
79 {
"$hour_minutes_seconds", locale.GetInfo(wxLOCALE_TIME_FMT)},
81 {
"$long_date_time",
"%x %X"},
84 {
"$weekday_short_date_time",
"%a %x %X"},
85 {
"$weekday_short_date",
"%a %x"},
86 {
"$short_date_time",
"%x %X"},
87 {
"$short_date",
"%x"},
88 {
"$hour_minutes_seconds",
"%X"},
90 {
"$hour_minutes",
"%H:%M"},
91 {
"$24_hour_minutes_seconds",
"%H:%M:%S"},
93 wxString format =
options.format_string;
95 format =
"$weekday_short_date_time";
99 for (
const auto& pair : formatMap) {
100 if (format.Contains(pair.first)) {
101 format.Replace(pair.first, pair.second);
106 format.Replace(wxString(wxUniChar(0x202F)),
" ");
109 if (effective_time_zone ==
"Local Time") {
110 wxDateTime now = wxDateTime::Now();
111 if ((now == (now.ToGMT())) &&
113 t.Add(wxTimeSpan(1, 0, 0, 0));
123 tzName = t.Format(
"%Z");
126 }
else if (effective_time_zone ==
"LMT") {
130 if (std::isnan(
options.longitude)) {
131 t = wxInvalidDateTime;
133 t.Add(wxTimeSpan(0, 0, wxLongLong(
options.longitude * 3600. / 15.)));
140 wxString formattedDate = t.Format(format);
142 return formattedDate +
" " + tzName;
144 return formattedDate;