diff --git a/config.def.h b/config.def.h index 3a45ee23c5..e9cadb4165 100644 --- a/config.def.h +++ b/config.def.h @@ -705,6 +705,8 @@ static const unsigned menu_thumbnails_default = 3; static const unsigned menu_left_thumbnails_default = 0; +static const unsigned menu_timedate_style = 5; + static const bool xmb_vertical_thumbnails = false; #ifdef IOS diff --git a/configuration.c b/configuration.c index 0282ca2acc..654f193923 100644 --- a/configuration.c +++ b/configuration.c @@ -1574,6 +1574,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, #ifdef HAVE_MENU SETTING_UINT("dpi_override_value", &settings->uints.menu_dpi_override_value, true, menu_dpi_override_value, false); SETTING_UINT("menu_thumbnails", &settings->uints.menu_thumbnails, true, menu_thumbnails_default, false); + SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, menu_timedate_style, false); #ifdef HAVE_XMB SETTING_UINT("menu_left_thumbnails", &settings->uints.menu_left_thumbnails, true, menu_left_thumbnails_default, false); SETTING_UINT("xmb_alpha_factor", &settings->uints.menu_xmb_alpha_factor, true, xmb_alpha_factor, false); diff --git a/configuration.h b/configuration.h index 865f7058d9..28f599ff87 100644 --- a/configuration.h +++ b/configuration.h @@ -393,6 +393,7 @@ typedef struct settings unsigned video_record_scale_factor; unsigned video_stream_scale_factor; + unsigned menu_timedate_style; unsigned menu_thumbnails; unsigned menu_left_thumbnails; unsigned menu_dpi_override_value; diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 2dcb447fa8..1be69e735f 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1111,6 +1111,8 @@ MSG_HASH(MENU_ENUM_LABEL_THUMBNAILS_UPDATER_LIST, "thumbnails_updater_list") MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_ENABLE, "menu_timedate_enable") +MSG_HASH(MENU_ENUM_LABEL_TIMEDATE_STYLE, + "menu_timedate_style") MSG_HASH(MENU_ENUM_LABEL_TITLE_COLOR, "menu_title_color") MSG_HASH(MENU_ENUM_LABEL_UI_COMPANION_ENABLE, diff --git a/intl/msg_hash_us.c b/intl/msg_hash_us.c index a3799a3a80..83db0a6a8e 100644 --- a/intl/msg_hash_us.c +++ b/intl/msg_hash_us.c @@ -1738,6 +1738,10 @@ int menu_hash_get_help_us_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Shows current date and/or time inside menu."); break; + case MENU_ENUM_LABEL_TIMEDATE_STYLE: + snprintf(s, len, + "Style to show the current date and/or time in."); + break; case MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE: snprintf(s, len, "Shows current battery level inside menu."); diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 08a8b5b0a5..ae8017977e 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2906,6 +2906,46 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_TIMEDATE_ENABLE, "Show date / time" ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE, + "Style of date / time" + ) + MSG_HASH( + MENU_ENUM_SUBLABEL_TIMEDATE_STYLE, + "Changes the style current date and/or time is shown inside the menu." + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + "YYYY-MM-DD HH:MM:SS" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + "YYYY-MM-DD HH:MM" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + "MM-DD-YYYY HH:MM" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + "HH:MM:SS" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM, + "HH:MM" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM, + "DD/MM HH:MM" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MD_HM, + "MM/DD HH:MM" + ) + MSG_HASH( + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_AM_PM, + "HH:MM:SS (AM/PM)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_TITLE_COLOR, "Menu title color" diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 60fb1deabd..32d6c2b5d5 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -296,6 +296,7 @@ default_sublabel_macro(action_bind_sublabel_pointer_enable, MENU_ default_sublabel_macro(action_bind_sublabel_thumbnails, MENU_ENUM_SUBLABEL_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_left_thumbnails, MENU_ENUM_SUBLABEL_LEFT_THUMBNAILS) default_sublabel_macro(action_bind_sublabel_timedate_enable, MENU_ENUM_SUBLABEL_TIMEDATE_ENABLE) +default_sublabel_macro(action_bind_sublabel_timedate_style, MENU_ENUM_SUBLABEL_TIMEDATE_STYLE) default_sublabel_macro(action_bind_sublabel_battery_level_enable, MENU_ENUM_SUBLABEL_BATTERY_LEVEL_ENABLE) default_sublabel_macro(action_bind_sublabel_navigation_wraparound, MENU_ENUM_SUBLABEL_NAVIGATION_WRAPAROUND) default_sublabel_macro(action_bind_sublabel_audio_resampler_quality, MENU_ENUM_SUBLABEL_AUDIO_RESAMPLER_QUALITY) @@ -1290,6 +1291,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_TIMEDATE_ENABLE: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_enable); break; + case MENU_ENUM_LABEL_TIMEDATE_STYLE: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_style); + break; case MENU_ENUM_LABEL_THUMBNAILS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_thumbnails); break; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index e7d4d982de..346be1ab5d 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -596,7 +596,7 @@ static void rgui_render(void *data, bool is_idle) datetime.s = timedate; datetime.len = sizeof(timedate); - datetime.time_mode = 3; + datetime.time_mode = 4; menu_display_timedate(&datetime); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3619e86139..7cfa999fcf 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -3636,7 +3636,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info) datetime.s = timedate; datetime.len = sizeof(timedate); - datetime.time_mode = 4; + datetime.time_mode = settings->uints.menu_timedate_style; menu_display_timedate(&datetime); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 3ac166301d..ae39a02992 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5779,6 +5779,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_TIMEDATE_ENABLE, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_TIMEDATE_STYLE, + PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 6075c63c2c..0ec43c8325 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -17,13 +17,14 @@ #include #include - +#include #include #include #include #include #include #include +#include #ifdef WIIU #include @@ -346,28 +347,58 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime) time(&time_); + setlocale(LC_TIME, ""); + switch (datetime->time_mode) { case 0: /* Date and time */ strftime(datetime->s, datetime->len, "%Y-%m-%d %H:%M:%S", localtime(&time_)); break; - case 1: /* Date */ + case 1: /* YY-MM-DD HH:MM */ strftime(datetime->s, datetime->len, - "%Y-%m-%d", localtime(&time_)); + "%Y-%m-%d %H:%M", localtime(&time_)); break; - case 2: /* Time */ + case 2: /* MM-DD-YYYY HH:MM */ + strftime(datetime->s, datetime->len, + "%m-%d-%Y %H:%M", localtime(&time_)); + break; + case 3: /* Time */ strftime(datetime->s, datetime->len, "%H:%M:%S", localtime(&time_)); break; - case 3: /* Time (hours-minutes) */ + case 4: /* Time (hours-minutes) */ strftime(datetime->s, datetime->len, "%H:%M", localtime(&time_)); break; - case 4: /* Date and time, without year and seconds */ + case 5: /* Date and time, without year and seconds */ strftime(datetime->s, datetime->len, "%d/%m %H:%M", localtime(&time_)); break; + case 6: + strftime(datetime->s, datetime->len, + "%m/%d %H:%M", localtime(&time_)); + break; + case 7: /* Time (hours-minutes), in 12 hour AM-PM designation */ +#if defined(__linux__) && !defined(ANDROID) + strftime(datetime->s, datetime->len, + "%r", localtime(&time_)); +#else + { + char *local; + + strftime(datetime->s, datetime->len, + + "%I:%M:%S %p", localtime(&time_)); + local = local_to_utf8_string_alloc(datetime->s); + + if (local) + { + strlcpy(datetime->s, local, datetime->len); + free(local); + } + } +#endif } } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 947f284381..0f6b8e889b 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -505,6 +505,56 @@ static void setting_get_string_representation_uint_menu_left_thumbnails( } } +static void setting_get_string_representation_uint_menu_timedate_style( + rarch_setting_t *setting, + char *s, size_t len) +{ + if (!setting) + return; + + 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; + } +} + static void setting_get_string_representation_uint_xmb_icon_theme( rarch_setting_t *setting, char *s, size_t len) @@ -8317,6 +8367,21 @@ static bool setting_append_list( general_read_handler, SD_FLAG_ADVANCED); + CONFIG_UINT(list, list_info, + &settings->uints.menu_timedate_style, + MENU_ENUM_LABEL_TIMEDATE_STYLE, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE, + menu_timedate_style, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + (*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); + CONFIG_BOOL( list, list_info, &settings->bools.menu_battery_level_enable, diff --git a/msg_hash.h b/msg_hash.h index 60d5dce122..bce6ce1de8 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -833,6 +833,7 @@ enum msg_hash_enums MENU_LABEL(LEFT_THUMBNAILS), MENU_LABEL(XMB_VERTICAL_THUMBNAILS), MENU_LABEL(TIMEDATE_ENABLE), + MENU_LABEL(TIMEDATE_STYLE), MENU_LABEL(BATTERY_LEVEL_ENABLE), MENU_LABEL(MATERIALUI_MENU_COLOR_THEME), MENU_LABEL(QUICK_MENU_OVERRIDE_OPTIONS), @@ -2129,6 +2130,14 @@ enum msg_hash_enums MSG_CHEAT_SEARCH_ADD_MATCH_FAIL, MSG_CHEAT_SEARCH_DELETE_MATCH_SUCCESS, MSG_CHEEVOS_HARDCORE_MODE_DISABLED, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HM, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_MDYYYY, + MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS, + 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, #ifdef HAVE_LAKKA_SWITCH MENU_ENUM_LABEL_SWITCH_GPU_PROFILE,