40wxString toUsrDateTimeFormat(
const wxDateTime date_time,
42#
if wxCHECK_VERSION(3, 1, 6)
44 const wxUILocale& locale
47 wxDateTime t(date_time);
48 wxString effective_time_zone =
options.time_zone;
49 if (effective_time_zone == wxEmptyString) {
50 effective_time_zone = ::g_datetime_format;
52 if (effective_time_zone == wxEmptyString) {
53 effective_time_zone =
"UTC";
56 wxString aform = androidGetLocalizedDateTime(
options, date_time);
57 if (!aform.IsEmpty())
return aform;
61 std::vector<std::pair<wxString, wxString>> formatMap = {
62#if wxCHECK_VERSION(3, 1, 6)
65 {
"$long_date_time", locale.GetInfo(wxLOCALE_LONG_DATE_FMT) +
" " +
66 locale.GetInfo(wxLOCALE_TIME_FMT)},
67 {
"$long_date", locale.GetInfo(wxLOCALE_LONG_DATE_FMT)},
68 {
"$weekday_short_date_time",
"%a " +
69 locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
70 " " + locale.GetInfo(wxLOCALE_TIME_FMT)},
71 {
"$weekday_short_date",
"%a " + locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
72 {
"$short_date_time", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT) +
" " +
73 locale.GetInfo(wxLOCALE_TIME_FMT)},
74 {
"$short_date", locale.GetInfo(wxLOCALE_SHORT_DATE_FMT)},
75 {
"$hour_minutes_seconds", locale.GetInfo(wxLOCALE_TIME_FMT)},
77 {
"$long_date_time",
"%x %X"},
80 {
"$weekday_short_date_time",
"%a %x %X"},
81 {
"$weekday_short_date",
"%a %x"},
82 {
"$short_date_time",
"%x %X"},
83 {
"$short_date",
"%x"},
84 {
"$hour_minutes_seconds",
"%X"},
86 {
"$hour_minutes",
"%H:%M"},
87 {
"$24_hour_minutes_seconds",
"%H:%M:%S"},
89 wxString format =
options.format_string;
90 if (format == wxEmptyString) {
91 format =
"$weekday_short_date_time";
95 for (
const auto& pair : formatMap) {
96 if (format.Contains(pair.first)) {
97 format.Replace(pair.first, pair.second);
102 format.Replace(wxString(wxUniChar(0x202F)),
" ");
105 if (effective_time_zone ==
"Local Time") {
106 wxDateTime now = wxDateTime::Now();
107 if ((now == (now.ToGMT())) &&
109 t.Add(wxTimeSpan(1, 0, 0, 0));
119 tzName = t.Format(
"%Z");
122 }
else if (effective_time_zone ==
"LMT") {
126 if (std::isnan(
options.longitude)) {
127 t = wxInvalidDateTime;
129 t.Add(wxTimeSpan(0, 0, wxLongLong(
options.longitude * 3600. / 15.)));
136 wxString formattedDate = t.Format(format);
138 return formattedDate +
" " + tzName;
140 return formattedDate;