mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-23 07:59:42 +00:00
Revert "Move strftime_am_pm to libretro-common rtime.c, remove duplicate"
This reverts commit 99186b1056
.
This commit is contained in:
parent
99186b1056
commit
06e1b6a68f
@ -40,11 +40,6 @@ void rtime_init(void);
|
||||
/* Must be called upon program termination */
|
||||
void rtime_deinit(void);
|
||||
|
||||
/* Time format strings with AM-PM designation require special
|
||||
* handling due to platform dependence */
|
||||
void strftime_am_pm(char *s, size_t len, const char* format,
|
||||
const struct tm* timeptr);
|
||||
|
||||
/* Thread-safe wrapper for localtime() */
|
||||
struct tm *rtime_localtime(const time_t *timep, struct tm *result);
|
||||
|
||||
|
@ -27,13 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
#include <time/rtime.h>
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#if !(defined(__linux__) && !defined(ANDROID))
|
||||
#include <encodings/utf.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_THREADS
|
||||
/* TODO/FIXME - global */
|
||||
@ -85,27 +79,3 @@ struct tm *rtime_localtime(const time_t *timep, struct tm *result)
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Time format strings with AM-PM designation require special
|
||||
* handling due to platform dependence */
|
||||
void strftime_am_pm(char *s, size_t len, const char* format,
|
||||
const struct tm* timeptr)
|
||||
{
|
||||
char *local = NULL;
|
||||
|
||||
/* Ensure correct locale is set
|
||||
* > Required for localised AM/PM strings */
|
||||
setlocale(LC_TIME, "");
|
||||
|
||||
strftime(s, len, format, timeptr);
|
||||
#if !(defined(__linux__) && !defined(ANDROID))
|
||||
if ((local = local_to_utf8_string_alloc(s)))
|
||||
{
|
||||
if (!string_is_empty(local))
|
||||
strlcpy(s, local, len);
|
||||
|
||||
free(local);
|
||||
local = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -636,6 +636,32 @@ bool menu_entries_list_search(const char *needle, size_t *idx)
|
||||
return match_found;
|
||||
}
|
||||
|
||||
/* Time format strings with AM-PM designation require special
|
||||
* handling due to platform dependence */
|
||||
static void strftime_am_pm(char *s, size_t len, const char* format,
|
||||
const struct tm* timeptr)
|
||||
{
|
||||
char *local = NULL;
|
||||
|
||||
/* Ensure correct locale is set
|
||||
* > Required for localised AM/PM strings */
|
||||
setlocale(LC_TIME, "");
|
||||
|
||||
strftime(s, len, format, timeptr);
|
||||
#if !(defined(__linux__) && !defined(ANDROID))
|
||||
local = local_to_utf8_string_alloc(s);
|
||||
if (local)
|
||||
{
|
||||
if (!string_is_empty(local))
|
||||
strlcpy(s, local, len);
|
||||
|
||||
free(local);
|
||||
local = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* Display the date and time - time_mode will influence how
|
||||
* the time representation will look like.
|
||||
* */
|
||||
|
@ -62,9 +62,11 @@ static bool RtlJSONObjectMemberHandler(void *ctx, const char *s, size_t len)
|
||||
{
|
||||
RtlJSONContext *p_ctx = (RtlJSONContext*)ctx;
|
||||
|
||||
/* something went wrong */
|
||||
if (p_ctx->current_entry_val)
|
||||
{
|
||||
/* something went wrong */
|
||||
return false;
|
||||
}
|
||||
|
||||
if (len)
|
||||
{
|
||||
@ -127,7 +129,8 @@ static void runtime_log_read_file(runtime_log_t *runtime_log)
|
||||
}
|
||||
|
||||
/* Initialise JSON parser */
|
||||
if (!(parser = rjson_open_rfile(file)))
|
||||
parser = rjson_open_rfile(file);
|
||||
if (!parser)
|
||||
{
|
||||
RARCH_ERR("Failed to create JSON parser.\n");
|
||||
goto end;
|
||||
@ -374,8 +377,9 @@ runtime_log_t *runtime_log_init(
|
||||
|
||||
/* Phew... If we get this far then all is well.
|
||||
* > Create 'runtime_log' object */
|
||||
if (!(runtime_log = (runtime_log_t*)
|
||||
malloc(sizeof(*runtime_log))))
|
||||
runtime_log = (runtime_log_t*)
|
||||
malloc(sizeof(*runtime_log));
|
||||
if (!runtime_log)
|
||||
return NULL;
|
||||
|
||||
/* > Populate default values */
|
||||
@ -621,6 +625,29 @@ void runtime_log_get_last_played_time(runtime_log_t *runtime_log,
|
||||
mktime(time_info);
|
||||
}
|
||||
|
||||
static void last_played_strftime(char *s, size_t len, const char *format,
|
||||
const struct tm *timeptr)
|
||||
{
|
||||
char *local = NULL;
|
||||
|
||||
/* Ensure correct locale is set */
|
||||
setlocale(LC_TIME, "");
|
||||
|
||||
/* Generate string */
|
||||
strftime(s, len, format, timeptr);
|
||||
#if !(defined(__linux__) && !defined(ANDROID))
|
||||
local = local_to_utf8_string_alloc(s);
|
||||
if (local)
|
||||
{
|
||||
if (!string_is_empty(local))
|
||||
strlcpy(s, local, len);
|
||||
|
||||
free(local);
|
||||
local = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void last_played_human(runtime_log_t *runtime_log,
|
||||
char *str, size_t len)
|
||||
{
|
||||
@ -828,7 +855,7 @@ void runtime_log_get_last_played_str(runtime_log_t *runtime_log,
|
||||
/* Get time */
|
||||
struct tm time_info;
|
||||
runtime_log_get_last_played_time(runtime_log, &time_info);
|
||||
strftime_am_pm(tmp, sizeof(tmp), format_str, &time_info);
|
||||
last_played_strftime(tmp, sizeof(tmp), format_str, &time_info);
|
||||
}
|
||||
snprintf(str, len, "%s%s",
|
||||
msg_hash_to_str(
|
||||
|
Loading…
Reference in New Issue
Block a user