diff --git a/config.def.h b/config.def.h index c82bb3f548..88a931c393 100644 --- a/config.def.h +++ b/config.def.h @@ -944,7 +944,9 @@ static const unsigned menu_left_thumbnails_default = 0; static const unsigned menu_thumbnail_upscale_threshold = 0; -static const unsigned menu_timedate_style = 5; +#ifdef HAVE_MENU +static const unsigned menu_timedate_style = MENU_TIMEDATE_STYLE_DM_HM; +#endif static const bool xmb_vertical_thumbnails = false; diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 126ee99bdd..f93e42aed4 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -1751,7 +1751,7 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, "MM/DD HH:MM") MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)") MSG_HASH(MENU_ENUM_LABEL_VALUE_TRUE, "是") diff --git a/intl/msg_hash_el.h b/intl/msg_hash_el.h index 72ed2cfe0f..fdc3312de8 100644 --- a/intl/msg_hash_el.h +++ b/intl/msg_hash_el.h @@ -2951,7 +2951,7 @@ MSG_HASH( "ΜΜ/ΗΗ ΩΩ:ΛΛ" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "ΩΩ:ΛΛ:ΔΔ (ΠΜ/ΜΜ)" ) MSG_HASH( diff --git a/intl/msg_hash_es.h b/intl/msg_hash_es.h index c5ca918e2a..c1474c335a 100644 --- a/intl/msg_hash_es.h +++ b/intl/msg_hash_es.h @@ -3019,7 +3019,7 @@ MSG_HASH( "MM/DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 6d1f044e15..8ebdd347bc 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3220,7 +3220,7 @@ MSG_HASH( "MM/JJ HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 682e163c0d..814c498776 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3408,7 +3408,7 @@ MSG_HASH( "月/日 時:分" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "時:分:秒 (午前/午後)" ) MSG_HASH( diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 3cbc5db712..8dbf7af14f 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3387,7 +3387,7 @@ MSG_HASH( "MM/DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 156939f60b..ee5c1a7fd4 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -3387,7 +3387,7 @@ MSG_HASH( "MM/DD HH:MM" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_tr.h b/intl/msg_hash_tr.h index cc7901188d..fc17b23fda 100644 --- a/intl/msg_hash_tr.h +++ b/intl/msg_hash_tr.h @@ -3315,7 +3315,7 @@ MSG_HASH( "AA/GG SS:DD" ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "SS:DD:SN (AM/PM)" ) MSG_HASH( diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index bede1b98f9..481537193a 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3378,10 +3378,34 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, "MM/DD HH:MM" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + "YYYY-MM-DD HH:MM:SS (AM/PM)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + "YYYY-MM-DD HH:MM (AM/PM)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_AM_PM, + "MM-DD-YYYY HH:MM (AM/PM)" + ) MSG_HASH( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, "HH:MM:SS (AM/PM)" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + "HH:MM (AM/PM)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM_AM_PM, + "DD/MM HH:MM (AM/PM)" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, + "MM/DD HH:MM (AM/PM)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_MENU_TICKER_TYPE, "Ticker Text Animation" diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 04ac6e7a91..84a4e6d0a8 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -3761,7 +3761,7 @@ static void rgui_render(void *data, datetime.s = timedate; datetime.len = sizeof(timedate); - datetime.time_mode = 4; + datetime.time_mode = MENU_TIMEDATE_STYLE_HM; menu_display_timedate(&datetime); diff --git a/menu/menu_defines.h b/menu/menu_defines.h index 0d9dcffbac..50e2dca678 100644 --- a/menu/menu_defines.h +++ b/menu/menu_defines.h @@ -86,6 +86,25 @@ enum rarch_menu_ctl_state MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL }; +enum menu_timedate_style_type +{ + MENU_TIMEDATE_STYLE_YMD_HMS = 0, + MENU_TIMEDATE_STYLE_YMD_HM, + MENU_TIMEDATE_STYLE_MDYYYY, + MENU_TIMEDATE_STYLE_HMS, + MENU_TIMEDATE_STYLE_HM, + MENU_TIMEDATE_STYLE_DM_HM, + MENU_TIMEDATE_STYLE_MD_HM, + MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_TIMEDATE_STYLE_MDYYYY_AM_PM, + MENU_TIMEDATE_STYLE_HMS_AM_PM, + MENU_TIMEDATE_STYLE_HM_AM_PM, + MENU_TIMEDATE_STYLE_DM_HM_AM_PM, + MENU_TIMEDATE_STYLE_MD_HM_AM_PM, + MENU_TIMEDATE_STYLE_LAST +}; + enum rgui_color_theme { RGUI_THEME_CUSTOM = 0, diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 81696e04dc..2bdd24d9cf 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -1650,6 +1650,30 @@ static bool menu_display_check_compatibility( return false; } +/* Time format strings with AM-PM designation require special + * handling due to platform dependence */ +static void strftime_am_pm(char* ptr, size_t maxsize, const char* format, + const struct tm* timeptr) +{ + char *local = NULL; + +#if defined(__linux__) && !defined(ANDROID) + strftime(ptr, maxsize, format, timeptr); +#else + strftime(ptr, maxsize, format, timeptr); + local = local_to_utf8_string_alloc(ptr); + + if (!string_is_empty(local)) + strlcpy(ptr, local, maxsize); + + if (local) + { + free(local); + local = NULL; + } +#endif +} + /* Display the date and time - time_mode will influence how * the time representation will look like. * */ @@ -1677,55 +1701,62 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime) /* Format string representation */ switch (datetime->time_mode) { - case 0: /* Date and time */ + case MENU_TIMEDATE_STYLE_YMD_HMS: /* YYYY-MM-DD HH:MM:SS */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%Y-%m-%d %H:%M:%S", tm_); break; - case 1: /* YY-MM-DD HH:MM */ + case MENU_TIMEDATE_STYLE_YMD_HM: /* YYYY-MM-DD HH:MM */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%Y-%m-%d %H:%M", tm_); break; - case 2: /* MM-DD-YYYY HH:MM */ + case MENU_TIMEDATE_STYLE_MDYYYY: /* MM-DD-YYYY HH:MM */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%m-%d-%Y %H:%M", tm_); break; - case 3: /* Time */ + case MENU_TIMEDATE_STYLE_HMS: /* HH:MM:SS */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%H:%M:%S", tm_); break; - case 4: /* Time (hours-minutes) */ + case MENU_TIMEDATE_STYLE_HM: /* HH:MM */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%H:%M", tm_); break; - case 5: /* Date and time, without year and seconds */ + case MENU_TIMEDATE_STYLE_DM_HM: /* DD/MM HH:MM */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%d/%m %H:%M", tm_); break; - case 6: + case MENU_TIMEDATE_STYLE_MD_HM: /* MM/DD HH:MM */ strftime(menu_datetime_cache, sizeof(menu_datetime_cache), "%m/%d %H:%M", tm_); break; - case 7: /* Time (hours-minutes), in 12 hour AM-PM designation */ -#if defined(__linux__) && !defined(ANDROID) - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), - "%I : %M : %S %p", tm_); -#else - { - char *local; - - strftime(menu_datetime_cache, sizeof(menu_datetime_cache), - + case MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM: /* YYYY-MM-DD HH:MM:SS (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%Y-%m-%d %I:%M:%S %p", tm_); + break; + case MENU_TIMEDATE_STYLE_YMD_HM_AM_PM: /* YYYY-MM-DD HH:MM (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%Y-%m-%d %I:%M %p", tm_); + break; + case MENU_TIMEDATE_STYLE_MDYYYY_AM_PM: /* MM-DD-YYYY HH:MM (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%m-%d-%Y %I:%M %p", tm_); + break; + case MENU_TIMEDATE_STYLE_HMS_AM_PM: /* HH:MM:SS (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), "%I:%M:%S %p", tm_); - local = local_to_utf8_string_alloc(menu_datetime_cache); - - if (local) - { - strlcpy(menu_datetime_cache, - local, sizeof(menu_datetime_cache)); - free(local); - } - } -#endif + break; + case MENU_TIMEDATE_STYLE_HM_AM_PM: /* HH:MM (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%I:%M %p", tm_); + break; + case MENU_TIMEDATE_STYLE_DM_HM_AM_PM: /* DD/MM HH:MM (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%d/%m %I:%M %p", tm_); + break; + case MENU_TIMEDATE_STYLE_MD_HM_AM_PM: /* MM/DD HH:MM (am/pm) */ + strftime_am_pm(menu_datetime_cache, sizeof(menu_datetime_cache), + "%m/%d %I:%M %p", tm_); + break; } } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 7ec520fcc9..f5364dc2b0 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3133,44 +3133,74 @@ static void setting_get_string_representation_uint_menu_timedate_style( switch (*setting->value.target.unsigned_integer) { - case 0: - strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS), len); - break; - case 1: - strlcpy(s, msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM), len); - break; - case 2: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY), len); - break; - case 3: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS), len); - break; - case 4: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM), len); - break; - case 5: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM), len); - break; - case 6: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM), len); - break; - case 7: - strlcpy(s, - msg_hash_to_str( - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM), len); - break; + case MENU_TIMEDATE_STYLE_YMD_HMS: + strlcpy(s, msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS), len); + break; + case MENU_TIMEDATE_STYLE_YMD_HM: + strlcpy(s, msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM), len); + break; + case MENU_TIMEDATE_STYLE_MDYYYY: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY), len); + break; + case MENU_TIMEDATE_STYLE_HMS: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS), len); + break; + case MENU_TIMEDATE_STYLE_HM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM), len); + break; + case MENU_TIMEDATE_STYLE_DM_HM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM), len); + break; + case MENU_TIMEDATE_STYLE_MD_HM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM), len); + break; + case MENU_TIMEDATE_STYLE_YMD_HMS_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_YMD_HM_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_MDYYYY_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_HMS_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_HM_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_DM_HM_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM_AM_PM), len); + break; + case MENU_TIMEDATE_STYLE_MD_HM_AM_PM: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM), len); + break; } } @@ -13077,7 +13107,7 @@ static bool setting_append_list( (*list)[list_info->index - 1].action_ok = &setting_action_ok_uint; (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_menu_timedate_style; - menu_settings_list_current_add_range(list, list_info, 0, 7, 1, true, true); + menu_settings_list_current_add_range(list, list_info, 0, MENU_TIMEDATE_STYLE_LAST - 1, 1, true, true); (*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX; CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index 7a4b3e8ea1..4c11a0da26 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -2510,7 +2510,13 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM, MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, - MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM_AM_PM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM_AM_PM, MENU_ENUM_LABEL_SWITCH_GPU_PROFILE, MENU_ENUM_LABEL_VALUE_SWITCH_GPU_PROFILE,