From 86a1d828c82fece7a0dd22dc1abb1abb721c3491 Mon Sep 17 00:00:00 2001 From: Alex Taber Date: Wed, 30 Aug 2017 10:06:51 -0400 Subject: [PATCH] Clean up format_time (Thanks LiquidFenrir) --- source/main.c | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/source/main.c b/source/main.c index 68579c1..a2940fa 100644 --- a/source/main.c +++ b/source/main.c @@ -71,29 +71,9 @@ int de_init_services(void) void format_time(char *time_string) { - time_t t = time(NULL); - struct tm tm = *localtime(&t); - if (tm.tm_hour < 10) - { - char temp_string[3] = {0}; - sprintf(temp_string, "0%i", tm.tm_hour); - strcat(time_string, temp_string); - } else { - char temp_string[3] = {0}; - sprintf(temp_string, "%i", tm.tm_hour); - strcat(time_string, temp_string); - } - strcat(time_string, ":"); - if (tm.tm_min < 10) - { - char temp_string[3] = {0}; - sprintf(temp_string, "0%i", tm.tm_min); - strcat(time_string, temp_string); - } else { - char temp_string[3] = {0}; - sprintf(temp_string, "%i", tm.tm_min); - strcat(time_string, temp_string); - } + time_t t = time(NULL); + struct tm tm = *localtime(&t); + sprintf(time_string, "%s%.2i:%.2i", time_string, tm.tm_hour, tm.tm_min); } Result MCUHWC_GetBatteryLevel(u8 *out) // Code taken from daedreth's fork of lpp-3ds