Enable configuration of date seperator in clock and runtime 'last played' displays

This commit is contained in:
jdgleaver 2020-05-25 15:46:53 +01:00
parent 089c64f427
commit 18912ac23d
18 changed files with 796 additions and 154 deletions

View file

@ -1078,7 +1078,8 @@ static const unsigned menu_left_thumbnails_default = 0;
static const unsigned gfx_thumbnail_upscale_threshold = 0;
#ifdef HAVE_MENU
static const unsigned menu_timedate_style = MENU_TIMEDATE_STYLE_DDMM_HM;
#define DEFAULT_MENU_TIMEDATE_STYLE MENU_TIMEDATE_STYLE_DDMM_HM
#define DEFAULT_MENU_TIMEDATE_DATE_SEPARATOR MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN
#endif
static const bool xmb_vertical_thumbnails = false;

View file

@ -1791,7 +1791,8 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings,
SETTING_UINT("menu_thumbnails", &settings->uints.gfx_thumbnails, true, gfx_thumbnails_default, false);
SETTING_UINT("menu_left_thumbnails", &settings->uints.menu_left_thumbnails, true, menu_left_thumbnails_default, false);
SETTING_UINT("menu_thumbnail_upscale_threshold", &settings->uints.gfx_thumbnail_upscale_threshold, true, gfx_thumbnail_upscale_threshold, false);
SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, menu_timedate_style, false);
SETTING_UINT("menu_timedate_style", &settings->uints.menu_timedate_style, true, DEFAULT_MENU_TIMEDATE_STYLE, false);
SETTING_UINT("menu_timedate_date_separator", &settings->uints.menu_timedate_date_separator, true, DEFAULT_MENU_TIMEDATE_DATE_SEPARATOR, false);
SETTING_UINT("menu_ticker_type", &settings->uints.menu_ticker_type, true, DEFAULT_MENU_TICKER_TYPE, false);
#ifdef HAVE_RGUI
SETTING_UINT("rgui_menu_color_theme", &settings->uints.menu_rgui_color_theme, true, DEFAULT_RGUI_COLOR_THEME, false);

View file

@ -545,6 +545,7 @@ typedef struct settings
unsigned accessibility_narrator_speech_speed;
unsigned menu_timedate_style;
unsigned menu_timedate_date_separator;
unsigned gfx_thumbnails;
unsigned menu_left_thumbnails;
unsigned gfx_thumbnail_upscale_threshold;

View file

@ -187,6 +187,7 @@ typedef struct gfx_display_ctx_datetime
char *s;
size_t len;
unsigned time_mode;
unsigned date_separator;
} gfx_display_ctx_datetime_t;
typedef struct gfx_display_ctx_powerstate

View file

@ -2666,6 +2666,10 @@ MSG_HASH(
MENU_ENUM_LABEL_TIMEDATE_STYLE,
"menu_timedate_style"
)
MSG_HASH(
MENU_ENUM_LABEL_TIMEDATE_DATE_SEPARATOR,
"menu_timedate_date_separator"
)
MSG_HASH(
MENU_ENUM_LABEL_MENU_TICKER_TYPE,
"menu_ticker_type"

View file

@ -3547,6 +3547,14 @@ 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_DATE_SEPARATOR,
"Date Separator"
)
MSG_HASH(
MENU_ENUM_SUBLABEL_TIMEDATE_DATE_SEPARATOR,
"Specifies character to use as a separator between year/month/day components when current date is shown inside the menu."
)
MSG_HASH(
MENU_ENUM_LABEL_VALUE_BATTERY_LEVEL_ENABLE,
"Show Battery Level"

View file

@ -454,6 +454,7 @@ default_sublabel_macro(action_bind_sublabel_ozone_scroll_content_metadata,
default_sublabel_macro(action_bind_sublabel_menu_thumbnail_upscale_threshold, MENU_ENUM_SUBLABEL_MENU_THUMBNAIL_UPSCALE_THRESHOLD)
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_timedate_date_separator, MENU_ENUM_SUBLABEL_TIMEDATE_DATE_SEPARATOR)
default_sublabel_macro(action_bind_sublabel_battery_level_enable, MENU_ENUM_SUBLABEL_BATTERY_LEVEL_ENABLE)
default_sublabel_macro(action_bind_sublabel_menu_show_sublabels, MENU_ENUM_SUBLABEL_MENU_SHOW_SUBLABELS)
default_sublabel_macro(action_bind_sublabel_navigation_wraparound, MENU_ENUM_SUBLABEL_NAVIGATION_WRAPAROUND)
@ -1090,6 +1091,10 @@ static int action_bind_sublabel_playlist_entry(
playlist_sublabel_last_played_style =
(enum playlist_sublabel_last_played_style_type)
settings->uints.playlist_sublabel_last_played_style;
enum playlist_sublabel_last_played_date_separator_type
menu_timedate_date_separator =
(enum playlist_sublabel_last_played_date_separator_type)
settings->uints.menu_timedate_date_separator;
if (!playlist_show_sublabels)
return 0;
@ -1149,7 +1154,8 @@ static int action_bind_sublabel_playlist_entry(
directory_runtime_log,
directory_playlist,
(playlist_sublabel_runtime_type == PLAYLIST_RUNTIME_PER_CORE),
playlist_sublabel_last_played_style);
playlist_sublabel_last_played_style,
menu_timedate_date_separator);
/* Check whether runtime info is valid */
if (entry->runtime_status == PLAYLIST_RUNTIME_VALID)
@ -2133,6 +2139,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs,
case MENU_ENUM_LABEL_TIMEDATE_STYLE:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_style);
break;
case MENU_ENUM_LABEL_TIMEDATE_DATE_SEPARATOR:
BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_timedate_date_separator);
break;
case MENU_ENUM_LABEL_THUMBNAILS:
{
const char *menu_ident = menu_driver_ident();

View file

@ -2903,6 +2903,10 @@ static bool materialui_render_process_entry_playlist_desktop(
runtime_last_played_style =
(enum playlist_sublabel_last_played_style_type)
settings->uints.playlist_sublabel_last_played_style;
enum playlist_sublabel_last_played_date_separator_type
runtime_date_separator =
(enum playlist_sublabel_last_played_date_separator_type)
settings->uints.menu_timedate_date_separator;
float fade_duration = gfx_thumbnail_get_fade_duration();
const struct playlist_entry *entry = NULL;
const char *core_name = NULL;
@ -2942,7 +2946,8 @@ static bool materialui_render_process_entry_playlist_desktop(
directory_runtime_log,
directory_playlist,
(runtime_type == PLAYLIST_RUNTIME_PER_CORE),
runtime_last_played_style);
runtime_last_played_style,
runtime_date_separator);
if (!string_is_empty(entry->runtime_str))
runtime_str = entry->runtime_str;
@ -4804,24 +4809,25 @@ static void materialui_render_header(
unsigned video_width, unsigned video_height)
{
char menu_title_buf[255];
settings_t *settings = config_get_ptr();
size_t menu_title_margin = 0;
int usable_sys_bar_width = (int)video_width - (int)mui->nav_bar_layout_width;
int usable_title_bar_width = usable_sys_bar_width;
size_t sys_bar_battery_width = 0;
size_t sys_bar_clock_width = 0;
int sys_bar_text_y = (int)(((float)mui->sys_bar_height / 2.0f) + (float)mui->font_data.hint.line_centre_offset);
int title_x = 0;
bool show_back_icon = menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL);
bool show_search_icon = mui->is_playlist || mui->is_file_list;
bool show_switch_view_icon = mui->is_playlist && mui->primary_thumbnail_available;
bool use_landscape_layout = !mui->is_portrait &&
settings_t *settings = config_get_ptr();
size_t menu_title_margin = 0;
int usable_sys_bar_width = (int)video_width - (int)mui->nav_bar_layout_width;
int usable_title_bar_width = usable_sys_bar_width;
size_t sys_bar_battery_width = 0;
size_t sys_bar_clock_width = 0;
int sys_bar_text_y = (int)(((float)mui->sys_bar_height / 2.0f) + (float)mui->font_data.hint.line_centre_offset);
int title_x = 0;
bool show_back_icon = menu_entries_ctl(MENU_ENTRIES_CTL_SHOW_BACK, NULL);
bool show_search_icon = mui->is_playlist || mui->is_file_list;
bool show_switch_view_icon = mui->is_playlist && mui->primary_thumbnail_available;
bool use_landscape_layout = !mui->is_portrait &&
(mui->last_landscape_layout_optimization != MATERIALUI_LANDSCAPE_LAYOUT_OPTIMIZATION_DISABLED);
const char *menu_title = mui->menu_title;
bool battery_level_enable = settings->bools.menu_battery_level_enable;
bool menu_timedate_enable = settings->bools.menu_timedate_enable;
unsigned menu_timedate_style = settings->uints.menu_timedate_style;
bool menu_core_enable = settings->bools.menu_core_enable;
const char *menu_title = mui->menu_title;
bool battery_level_enable = settings->bools.menu_battery_level_enable;
bool menu_timedate_enable = settings->bools.menu_timedate_enable;
unsigned menu_timedate_style = settings->uints.menu_timedate_style;
unsigned menu_timedate_date_separator = settings->uints.menu_timedate_date_separator;
bool menu_core_enable = settings->bools.menu_core_enable;
menu_title_buf[0] = '\0';
@ -4970,9 +4976,10 @@ static void materialui_render_header(
timedate_str[0] = '\0';
datetime.s = timedate_str;
datetime.len = sizeof(timedate_str);
datetime.time_mode = menu_timedate_style;
datetime.s = timedate_str;
datetime.len = sizeof(timedate_str);
datetime.time_mode = menu_timedate_style;
datetime.date_separator = menu_timedate_date_separator;
menu_display_timedate(&datetime);

View file

@ -1730,11 +1730,12 @@ static void ozone_draw_header(ozone_handle_t *ozone,
gfx_display_ctx_datetime_t datetime;
char timedate[255];
timedate[0] = '\0';
timedate[0] = '\0';
datetime.s = timedate;
datetime.time_mode = settings->uints.menu_timedate_style;
datetime.len = sizeof(timedate);
datetime.s = timedate;
datetime.time_mode = settings->uints.menu_timedate_style;
datetime.date_separator = settings->uints.menu_timedate_date_separator;
datetime.len = sizeof(timedate);
menu_display_timedate(&datetime);
@ -2059,6 +2060,10 @@ void ozone_update_content_metadata(ozone_handle_t *ozone)
runtime_last_played_style =
(enum playlist_sublabel_last_played_style_type)
settings->uints.playlist_sublabel_last_played_style;
enum playlist_sublabel_last_played_date_separator_type
runtime_date_separator =
(enum playlist_sublabel_last_played_date_separator_type)
settings->uints.menu_timedate_date_separator;
/* Must check whether core corresponds to 'viewer'
* content even when not using a playlist, otherwise
@ -2108,7 +2113,8 @@ void ozone_update_content_metadata(ozone_handle_t *ozone)
directory_runtime_log,
directory_playlist,
(runtime_type == PLAYLIST_RUNTIME_PER_CORE),
runtime_last_played_style);
runtime_last_played_style,
runtime_date_separator);
if (!string_is_empty(entry->runtime_str))
strlcpy(ozone->selection_playtime, entry->runtime_str, sizeof(ozone->selection_playtime));

View file

@ -3870,11 +3870,12 @@ static void rgui_render(void *data,
gfx_display_ctx_datetime_t datetime;
char timedate[16];
timedate[0] = '\0';
timedate[0] = '\0';
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = MENU_TIMEDATE_STYLE_HM;
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = MENU_TIMEDATE_STYLE_HM;
datetime.date_separator = MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN;
menu_display_timedate(&datetime);

View file

@ -4796,11 +4796,12 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
gfx_display_blend_end(userdata);
}
timedate[0] = '\0';
timedate[0] = '\0';
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = settings->uints.menu_timedate_style;
datetime.s = timedate;
datetime.len = sizeof(timedate);
datetime.time_mode = settings->uints.menu_timedate_style;
datetime.date_separator = settings->uints.menu_timedate_date_separator;
menu_display_timedate(&datetime);

View file

@ -116,6 +116,17 @@ enum menu_timedate_style_type
MENU_TIMEDATE_STYLE_LAST
};
/* Note: These must be kept synchronised with
* 'enum playlist_sublabel_last_played_date_separator_type'
* in 'runtime_file.h' */
enum menu_timedate_date_separator_type
{
MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN = 0,
MENU_TIMEDATE_DATE_SEPARATOR_SLASH,
MENU_TIMEDATE_DATE_SEPARATOR_PERIOD,
MENU_TIMEDATE_DATE_SEPARATOR_LAST
};
enum rgui_color_theme
{
RGUI_THEME_CUSTOM = 0,

View file

@ -3251,7 +3251,8 @@ static unsigned menu_displaylist_parse_content_information(
/* Last Played */
tmp[0] = '\0';
runtime_log_get_last_played_str(runtime_log, tmp, sizeof(tmp),
(enum playlist_sublabel_last_played_style_type)settings->uints.playlist_sublabel_last_played_style);
(enum playlist_sublabel_last_played_style_type)settings->uints.playlist_sublabel_last_played_style,
(enum playlist_sublabel_last_played_date_separator_type)settings->uints.menu_timedate_date_separator);
if (!string_is_empty(tmp))
if (menu_entries_append_enum(info->list, tmp,
@ -6496,6 +6497,7 @@ unsigned menu_displaylist_build_list(
{MENU_ENUM_LABEL_CONTENT_SHOW_PLAYLISTS, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_TIMEDATE_ENABLE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_TIMEDATE_STYLE, PARSE_ONLY_UINT, true },
{MENU_ENUM_LABEL_TIMEDATE_DATE_SEPARATOR, PARSE_ONLY_UINT, true },
{MENU_ENUM_LABEL_BATTERY_LEVEL_ENABLE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_CORE_ENABLE, PARSE_ONLY_BOOL, true },
{MENU_ENUM_LABEL_MENU_SHOW_SUBLABELS, PARSE_ONLY_BOOL, true },

View file

@ -2265,6 +2265,8 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
{
time_t time_;
const struct tm *tm_;
bool has_am_pm = false;
const char *format_str = "";
menu_st->datetime_last_time_us = menu_st->current_time_us;
@ -2279,110 +2281,347 @@ void menu_display_timedate(gfx_display_ctx_datetime_t *datetime)
switch (datetime->time_mode)
{
case MENU_TIMEDATE_STYLE_YMD_HMS: /* YYYY-MM-DD HH:MM:SS */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m-%d %H:%M:%S", tm_);
/* Using switch statements to set the format
* string is verbose, but has far less performance
* impact than setting the date separator dynamically
* (i.e. no snprintf() or character replacement...) */
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m/%d %H:%M:%S";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m.%d %H:%M:%S";
break;
default:
format_str = "%Y-%m-%d %H:%M:%S";
break;
}
break;
case MENU_TIMEDATE_STYLE_YMD_HM: /* YYYY-MM-DD HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m-%d %H:%M", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m/%d %H:%M";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m.%d %H:%M";
break;
default:
format_str = "%Y-%m-%d %H:%M";
break;
}
break;
case MENU_TIMEDATE_STYLE_YMD: /* YYYY-MM-DD */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m-%d", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m/%d";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m.%d";
break;
default:
format_str = "%Y-%m-%d";
break;
}
break;
case MENU_TIMEDATE_STYLE_YM: /* YYYY-MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m";
break;
default:
format_str = "%Y-%m";
break;
}
break;
case MENU_TIMEDATE_STYLE_MDYYYY_HMS: /* MM-DD-YYYY HH:MM:SS */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d-%Y %H:%M:%S", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d/%Y %H:%M:%S";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d.%Y %H:%M:%S";
break;
default:
format_str = "%m-%d-%Y %H:%M:%S";
break;
}
break;
case MENU_TIMEDATE_STYLE_MDYYYY_HM: /* MM-DD-YYYY HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d-%Y %H:%M", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d/%Y %H:%M";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d.%Y %H:%M";
break;
default:
format_str = "%m-%d-%Y %H:%M";
break;
}
break;
case MENU_TIMEDATE_STYLE_MD_HM: /* MM-DD HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d %H:%M", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d %H:%M";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d %H:%M";
break;
default:
format_str = "%m-%d %H:%M";
break;
}
break;
case MENU_TIMEDATE_STYLE_MDYYYY: /* MM-DD-YYYY */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d-%Y", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d/%Y";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d.%Y";
break;
default:
format_str = "%m-%d-%Y";
break;
}
break;
case MENU_TIMEDATE_STYLE_MD: /* MM-DD */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d";
break;
default:
format_str = "%m-%d";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS: /* DD-MM-YYYY HH:MM:SS */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m-%Y %H:%M:%S", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m/%Y %H:%M:%S";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m.%Y %H:%M:%S";
break;
default:
format_str = "%d-%m-%Y %H:%M:%S";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMMYYYY_HM: /* DD-MM-YYYY HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m-%Y %H:%M", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m/%Y %H:%M";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m.%Y %H:%M";
break;
default:
format_str = "%d-%m-%Y %H:%M";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMM_HM: /* DD-MM HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m %H:%M", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m %H:%M";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m %H:%M";
break;
default:
format_str = "%d-%m %H:%M";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMMYYYY: /* DD-MM-YYYY */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m-%Y", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m/%Y";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m.%Y";
break;
default:
format_str = "%d-%m-%Y";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMM: /* DD-MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m", tm_);
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m";
break;
default:
format_str = "%d-%m";
break;
}
break;
case MENU_TIMEDATE_STYLE_HMS: /* HH:MM:SS */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%H:%M:%S", tm_);
format_str = "%H:%M:%S";
break;
case MENU_TIMEDATE_STYLE_HM: /* HH:MM */
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%H:%M", tm_);
format_str = "%H:%M";
break;
case MENU_TIMEDATE_STYLE_YMD_HMS_AMPM: /* YYYY-MM-DD HH:MM:SS (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m-%d %I:%M:%S %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m/%d %I:%M:%S %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m.%d %I:%M:%S %p";
break;
default:
format_str = "%Y-%m-%d %I:%M:%S %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_YMD_HM_AMPM: /* YYYY-MM-DD HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%Y-%m-%d %I:%M %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%Y/%m/%d %I:%M %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%Y.%m.%d %I:%M %p";
break;
default:
format_str = "%Y-%m-%d %I:%M %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_MDYYYY_HMS_AMPM: /* MM-DD-YYYY HH:MM:SS (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d-%Y %I:%M:%S %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d/%Y %I:%M:%S %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d.%Y %I:%M:%S %p";
break;
default:
format_str = "%m-%d-%Y %I:%M:%S %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_MDYYYY_HM_AMPM: /* MM-DD-YYYY HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d-%Y %I:%M %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d/%Y %I:%M %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d.%Y %I:%M %p";
break;
default:
format_str = "%m-%d-%Y %I:%M %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_MD_HM_AMPM: /* MM-DD HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%m-%d %I:%M %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%m/%d %I:%M %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%m.%d %I:%M %p";
break;
default:
format_str = "%m-%d %I:%M %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMMYYYY_HMS_AMPM: /* DD-MM-YYYY HH:MM:SS (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m-%Y %I:%M:%S %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m/%Y %I:%M:%S %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m.%Y %I:%M:%S %p";
break;
default:
format_str = "%d-%m-%Y %I:%M:%S %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMMYYYY_HM_AMPM: /* DD-MM-YYYY HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m-%Y %I:%M %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m/%Y %I:%M %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m.%Y %I:%M %p";
break;
default:
format_str = "%d-%m-%Y %I:%M %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_DDMM_HM_AMPM: /* DD-MM HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%d-%m %I:%M %p", tm_);
has_am_pm = true;
switch (datetime->date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
format_str = "%d/%m %I:%M %p";
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
format_str = "%d.%m %I:%M %p";
break;
default:
format_str = "%d-%m %I:%M %p";
break;
}
break;
case MENU_TIMEDATE_STYLE_HMS_AMPM: /* HH:MM:SS (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%I:%M:%S %p", tm_);
has_am_pm = true;
format_str = "%I:%M:%S %p";
break;
case MENU_TIMEDATE_STYLE_HM_AMPM: /* HH:MM (AM/PM) */
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
"%I:%M %p", tm_);
has_am_pm = true;
format_str = "%I:%M %p";
break;
}
if (has_am_pm)
strftime_am_pm(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
format_str, tm_);
else
strftime(menu_st->datetime_cache, sizeof(menu_st->datetime_cache),
format_str, tm_);
}
/* Copy cached datetime string to input

View file

@ -3182,6 +3182,32 @@ static void setting_get_string_representation_uint_menu_left_thumbnails(
}
}
static void setting_set_string_representation_timedate_date_seperator(char *s)
{
settings_t *settings = config_get_ptr();
unsigned menu_timedate_date_separator = settings ?
settings->uints.menu_timedate_date_separator :
MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN;
char separator_char;
switch (menu_timedate_date_separator)
{
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
separator_char = '/';
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
separator_char = '.';
break;
case MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN:
default:
separator_char = '-';
break;
}
if (separator_char != '-')
string_replace_all_chars(s, '-', separator_char);
}
static void setting_get_string_representation_uint_menu_timedate_style(
rarch_setting_t *setting,
char *s, size_t len)
@ -3318,6 +3344,30 @@ static void setting_get_string_representation_uint_menu_timedate_style(
MENU_ENUM_LABEL_VALUE_TIMEDATE_HM_AMPM), len);
break;
}
/* Change date separator, if required */
setting_set_string_representation_timedate_date_seperator(s);
}
static void setting_get_string_representation_uint_menu_timedate_date_separator(
rarch_setting_t *setting,
char *s, size_t len)
{
if (!setting)
return;
switch (*setting->value.target.unsigned_integer)
{
case MENU_TIMEDATE_DATE_SEPARATOR_HYPHEN:
strlcpy(s, "'-'", len);
break;
case MENU_TIMEDATE_DATE_SEPARATOR_SLASH:
strlcpy(s, "'/'", len);
break;
case MENU_TIMEDATE_DATE_SEPARATOR_PERIOD:
strlcpy(s, "'.'", len);
break;
}
}
static void setting_get_string_representation_uint_rgui_menu_color_theme(
@ -4677,6 +4727,9 @@ static void setting_get_string_representation_uint_playlist_sublabel_last_played
len);
break;
}
/* Change date separator, if required */
setting_set_string_representation_timedate_date_seperator(s);
}
static void setting_get_string_representation_uint_playlist_inline_core_display_type(
@ -14372,7 +14425,7 @@ static bool setting_append_list(
&settings->uints.menu_timedate_style,
MENU_ENUM_LABEL_TIMEDATE_STYLE,
MENU_ENUM_LABEL_VALUE_TIMEDATE_STYLE,
menu_timedate_style,
DEFAULT_MENU_TIMEDATE_STYLE,
&group_info,
&subgroup_info,
parent_group,
@ -14384,6 +14437,22 @@ static bool setting_append_list(
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_UINT(list, list_info,
&settings->uints.menu_timedate_date_separator,
MENU_ENUM_LABEL_TIMEDATE_DATE_SEPARATOR,
MENU_ENUM_LABEL_VALUE_TIMEDATE_DATE_SEPARATOR,
DEFAULT_MENU_TIMEDATE_DATE_SEPARATOR,
&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_date_separator;
menu_settings_list_current_add_range(list, list_info, 0, MENU_TIMEDATE_DATE_SEPARATOR_LAST - 1, 1, true, true);
(*list)[list_info->index - 1].ui_type = ST_UI_TYPE_UINT_COMBOBOX;
CONFIG_BOOL(
list, list_info,
&settings->bools.menu_battery_level_enable,

View file

@ -1041,6 +1041,7 @@ enum msg_hash_enums
MENU_LABEL(MENU_RGUI_THUMBNAIL_DELAY),
MENU_LABEL(TIMEDATE_ENABLE),
MENU_LABEL(TIMEDATE_STYLE),
MENU_LABEL(TIMEDATE_DATE_SEPARATOR),
MENU_LABEL(BATTERY_LEVEL_ENABLE),
MENU_LABEL(MENU_SHOW_SUBLABELS),
MENU_LABEL(RGUI_MENU_COLOR_THEME),

View file

@ -694,9 +694,13 @@ static void last_played_strftime(runtime_log_t *runtime_log, char *str, size_t l
/* Gets last played entry value as a pre-formatted string */
void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
char *str, size_t len, enum playlist_sublabel_last_played_style_type timedate_style)
char *str, size_t len,
enum playlist_sublabel_last_played_style_type timedate_style,
enum playlist_sublabel_last_played_date_separator_type date_separator)
{
int n = 0;
bool has_am_pm = false;
const char *format_str = "";
int n = 0;
char tmp[64];
tmp[0] = '\0';
@ -708,127 +712,388 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
switch (timedate_style)
{
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y-%m-%d %I:%M:%S %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %Y-%m-%d %I:%M %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d-%Y %I:%M:%S %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d-%Y %I:%M %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %m-%d %I:%M %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m-%Y %I:%M:%S %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m-%Y %I:%M %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM:
last_played_strftime(runtime_log, tmp, sizeof(tmp), " %d-%m %I:%M %p");
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
default:
has_am_pm = true;
/* Using switch statements to set the format
* string is verbose, but has far less performance
* impact than setting the date separator dynamically
* (i.e. no snprintf() or character replacement...) */
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %Y/%m/%d %I:%M:%S %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %Y.%m.%d %I:%M:%S %p";
break;
default:
format_str = " %Y-%m-%d %I:%M:%S %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %Y/%m/%d %I:%M %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %Y.%m.%d %I:%M %p";
break;
default:
format_str = " %Y-%m-%d %I:%M %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %m/%d/%Y %I:%M:%S %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %m.%d.%Y %I:%M:%S %p";
break;
default:
format_str = " %m-%d-%Y %I:%M:%S %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %m/%d/%Y %I:%M %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %m.%d.%Y %I:%M %p";
break;
default:
format_str = " %m-%d-%Y %I:%M %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_MD_HM_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %m/%d %I:%M %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %m.%d %I:%M %p";
break;
default:
format_str = " %m-%d %I:%M %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %d/%m/%Y %I:%M:%S %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %d.%m.%Y %I:%M:%S %p";
break;
default:
format_str = " %d-%m-%Y %I:%M:%S %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %d/%m/%Y %I:%M %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %d.%m.%Y %I:%M %p";
break;
default:
format_str = " %d-%m-%Y %I:%M %p";
break;
}
break;
case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM_AMPM:
has_am_pm = true;
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = " %d/%m %I:%M %p";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = " %d.%m %I:%M %p";
break;
default:
format_str = " %d-%m %I:%M %p";
break;
}
break;
default:
has_am_pm = false;
break;
}
if (has_am_pm)
{
last_played_strftime(runtime_log, tmp, sizeof(tmp), format_str);
strlcpy(str, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED), len);
strlcat(str, tmp, len);
return;
}
/* Handle non-12-hour clock options */
switch (timedate_style)
{
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HM:
n = snprintf(str, len, "%s %04u-%02u-%02u %02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %04u/%02u/%02u %02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %04u.%02u.%02u %02u:%02u";
break;
default:
format_str = "%s %04u-%02u-%02u %02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day,
runtime_log->last_played.hour, runtime_log->last_played.minute);
return;
case PLAYLIST_LAST_PLAYED_STYLE_YMD:
n = snprintf(str, len, "%s %04u-%02u-%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %04u/%02u/%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %04u.%02u.%02u";
break;
default:
format_str = "%s %04u-%02u-%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day);
return;
case PLAYLIST_LAST_PLAYED_STYLE_YM:
n = snprintf(str, len, "%s %04u-%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %04u/%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %04u.%02u";
break;
default:
format_str = "%s %04u-%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.year, runtime_log->last_played.month);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HMS:
n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u %02u:%02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u %02u:%02u:%02u";
break;
default:
format_str = "%s %02u-%02u-%04u %02u:%02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year,
runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY_HM:
n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u %02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u %02u:%02u";
break;
default:
format_str = "%s %02u-%02u-%04u %02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year,
runtime_log->last_played.hour, runtime_log->last_played.minute);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MD_HM:
n = snprintf(str, len, "%s %02u-%02u %02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u %02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u %02u:%02u";
break;
default:
format_str = "%s %02u-%02u %02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.month, runtime_log->last_played.day,
runtime_log->last_played.hour, runtime_log->last_played.minute);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MDYYYY:
n = snprintf(str, len, "%s %02u-%02u-%04u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u";
break;
default:
format_str = "%s %02u-%02u-%04u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.month, runtime_log->last_played.day, runtime_log->last_played.year);
return;
case PLAYLIST_LAST_PLAYED_STYLE_MD:
n = snprintf(str, len, "%s %02u-%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u";
break;
default:
format_str = "%s %02u-%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.month, runtime_log->last_played.day);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HMS:
n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u %02u:%02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u %02u:%02u:%02u";
break;
default:
format_str = "%s %02u-%02u-%04u %02u:%02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year,
runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY_HM:
n = snprintf(str, len, "%s %02u-%02u-%04u %02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u %02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u %02u:%02u";
break;
default:
format_str = "%s %02u-%02u-%04u %02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year,
runtime_log->last_played.hour, runtime_log->last_played.minute);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMM_HM:
n = snprintf(str, len, "%s %02u-%02u %02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u %02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u %02u:%02u";
break;
default:
format_str = "%s %02u-%02u %02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.day, runtime_log->last_played.month,
runtime_log->last_played.hour, runtime_log->last_played.minute);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMMYYYY:
n = snprintf(str, len, "%s %02u-%02u-%04u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u/%04u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u.%04u";
break;
default:
format_str = "%s %02u-%02u-%04u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.day, runtime_log->last_played.month, runtime_log->last_played.year);
return;
case PLAYLIST_LAST_PLAYED_STYLE_DDMM:
n = snprintf(str, len, "%s %02u-%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %02u/%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %02u.%02u";
break;
default:
format_str = "%s %02u-%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.day, runtime_log->last_played.month);
return;
case PLAYLIST_LAST_PLAYED_STYLE_YMD_HMS:
default:
n = snprintf(str, len, "%s %04u-%02u-%02u %02u:%02u:%02u",
switch (date_separator)
{
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH:
format_str = "%s %04u/%02u/%02u %02u:%02u:%02u";
break;
case PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD:
format_str = "%s %04u.%02u.%02u %02u:%02u:%02u";
break;
default:
format_str = "%s %04u-%02u-%02u %02u:%02u:%02u";
break;
}
n = snprintf(str, len, format_str,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
runtime_log->last_played.year, runtime_log->last_played.month, runtime_log->last_played.day,
runtime_log->last_played.hour, runtime_log->last_played.minute, runtime_log->last_played.second);
@ -1013,7 +1278,8 @@ void runtime_update_playlist(
const char *dir_runtime_log,
const char *dir_playlist,
bool log_per_core,
enum playlist_sublabel_last_played_style_type timedate_style)
enum playlist_sublabel_last_played_style_type timedate_style,
enum playlist_sublabel_last_played_date_separator_type date_separator)
{
char runtime_str[64];
char last_played_str[64];
@ -1068,7 +1334,8 @@ void runtime_update_playlist(
&update_entry.last_played_year, &update_entry.last_played_month, &update_entry.last_played_day,
&update_entry.last_played_hour, &update_entry.last_played_minute, &update_entry.last_played_second);
runtime_log_get_last_played_str(runtime_log, last_played_str, sizeof(last_played_str), timedate_style);
runtime_log_get_last_played_str(runtime_log,
last_played_str, sizeof(last_played_str), timedate_style, date_separator);
/* Playlist entry now contains valid runtime data */
update_entry.runtime_status = PLAYLIST_RUNTIME_VALID;
@ -1087,7 +1354,8 @@ void runtime_update_playlist(
string_is_equal(menu_ident, "glui"))
{
runtime_log_get_runtime_str(NULL, runtime_str, sizeof(runtime_str));
runtime_log_get_last_played_str(NULL, last_played_str, sizeof(last_played_str), timedate_style);
runtime_log_get_last_played_str(NULL, last_played_str, sizeof(last_played_str),
timedate_style, date_separator);
/* While runtime data does not exist, the playlist
* entry does now contain valid information... */

View file

@ -84,6 +84,17 @@ enum playlist_sublabel_last_played_style_type
PLAYLIST_LAST_PLAYED_STYLE_LAST
};
/* Note: These must be kept synchronised with
* 'enum menu_timedate_date_separator_type' in
* 'menu_defines.h' */
enum playlist_sublabel_last_played_date_separator_type
{
PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_HYPHEN = 0,
PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_SLASH,
PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_PERIOD,
PLAYLIST_LAST_PLAYED_DATE_SEPARATOR_LAST
};
enum playlist_sublabel_runtime
{
PLAYLIST_RUNTIME_PER_CORE = 0,
@ -91,8 +102,6 @@ enum playlist_sublabel_runtime
PLAYLIST_RUNTIME_LAST
};
/* Initialisation */
/* Initialise runtime log, loading current parameters
@ -155,7 +164,9 @@ void runtime_log_get_last_played_time(runtime_log_t *runtime_log, struct tm *tim
/* Gets last played entry value as a pre-formatted string */
void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
char *str, size_t len, enum playlist_sublabel_last_played_style_type timedate_style);
char *str, size_t len,
enum playlist_sublabel_last_played_style_type timedate_style,
enum playlist_sublabel_last_played_date_separator_type date_separator);
/* Status */
@ -187,7 +198,8 @@ void runtime_update_playlist(
const char *dir_runtime_log,
const char *dir_playlist,
bool log_per_core,
enum playlist_sublabel_last_played_style_type timedate_style);
enum playlist_sublabel_last_played_style_type timedate_style,
enum playlist_sublabel_last_played_date_separator_type date_separator);
RETRO_END_DECLS