Linux friendly datetime locale settings, slightly less friendly datetime locale settings for Windows

This commit is contained in:
=Christian Murphy 2018-10-01 23:32:54 +01:00
parent b3cf7150d5
commit 940a03f552
6 changed files with 47 additions and 18 deletions

View File

@ -697,7 +697,7 @@ static const unsigned menu_thumbnails_default = 3;
static const unsigned menu_left_thumbnails_default = 0;
static const unsigned menu_timedate_style = 3;
static const unsigned menu_timedate_style = 4;
static const bool xmb_vertical_thumbnails = false;

View File

@ -2879,7 +2879,11 @@ MSG_HASH(
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD_HMS,
"YYYY-MM-DD H:M:S"
"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_YMD,
@ -2897,6 +2901,10 @@ 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 (AM/PM)"

View File

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

View File

@ -17,7 +17,7 @@
#include <string.h>
#include <time.h>
#include <locale.h>
#include <compat/strl.h>
#include <retro_miscellaneous.h>
#include <formats/image.h>
@ -346,32 +346,42 @@ 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: /* Date */
strftime(datetime->s, datetime->len,
"%y-%m-%d", 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 5: /* Time (hours-minutes), in 12 hour AM-PM designation */
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,
"%c", localtime(&time_));
"%r", localtime(&time_));
#else
strftime(datetime->s, datetime->len,
"%I:%M %p", localtime(&time_));

View File

@ -519,26 +519,35 @@ static void setting_get_string_representation_uint_menu_timedate_style(
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), len);
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_HMS), len);
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_YMD), len);
break;
case 3:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HM), len);
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_HMS), len);
break;
case 4:
strlcpy(s,
msg_hash_to_str(
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE_DM_HM), len);
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);
@ -8279,7 +8288,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, 5, 1, true, true);
menu_settings_list_current_add_range(list, list_info, 0, 7, 1, true, true);
CONFIG_BOOL(
list, list_info,

View File

@ -2128,10 +2128,12 @@ enum msg_hash_enums
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_YMD,
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,
MSG_LAST