Merge pull request #9456 from jdgleaver/date-format

Menu time/date: Add 12-hour versions of all formats + clean ups
This commit is contained in:
Twinaphex 2019-09-10 17:58:11 +02:00 committed by GitHub
commit f004666674
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 190 additions and 78 deletions

View File

@ -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;

View File

@ -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,
"")

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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(

View File

@ -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"

View File

@ -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);

View File

@ -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,

View File

@ -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;
}
}

View File

@ -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(

View File

@ -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,