From ed257e9216243f4831dfd54f34c4f97104890b95 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Tue, 8 Aug 2017 12:30:33 +0200 Subject: [PATCH] Use ISO 8601 for displaying date & time fixes #143 --- source/common/ui.c | 15 ++++++++------- source/godmode.c | 10 +++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/source/common/ui.c b/source/common/ui.c index 1235b0d..77006ff 100644 --- a/source/common/ui.c +++ b/source/common/ui.c @@ -619,8 +619,8 @@ bool ShowRtcSetterPrompt(void* time, const char *format, ...) { } str_width = GetDrawStringWidth(str); - str_height = GetDrawStringHeight(str) + (3*10); - if (str_width < (17 * FONT_WIDTH)) str_width = 17 * FONT_WIDTH; + str_height = GetDrawStringHeight(str) + (4*10); + if (str_width < (19 * FONT_WIDTH)) str_width = 19 * FONT_WIDTH; x = (str_width >= SCREEN_WIDTH_MAIN) ? 0 : (SCREEN_WIDTH_MAIN - str_width) / 2; y = (str_height >= SCREEN_HEIGHT) ? 0 : (SCREEN_HEIGHT - str_height) / 2; @@ -630,14 +630,15 @@ bool ShowRtcSetterPrompt(void* time, const char *format, ...) { int cursor = 0; bool ret = false; while (true) { - static const int val_max[] = { 23, 59, 59, 31, 12, 99 }; - static const int val_min[] = { 0, 0, 0, 1, 1, 0 }; - u8* bcd = &(((u8*)dstime)[(cursor<3) ? (2-cursor) : (cursor+1)]); + static const int val_max[] = { 99, 12, 31, 23, 59, 59 }; + static const int val_min[] = { 0, 1, 1, 0, 0, 0 }; + u8* bcd = &(((u8*)dstime)[(cursor<3) ? (6-cursor) : (6-1-cursor)]); int val = BCD2NUM(*bcd); int max = val_max[cursor]; int min = val_min[cursor]; - DrawStringF(MAIN_SCREEN, x, y + str_height - 18, COLOR_STD_FONT, COLOR_STD_BG, "%02lX:%02lX:%02lX %02lX/%02lX/%02lX\n%-*.*s^^%-*.*s", - (u32) dstime->bcd_h, (u32) dstime->bcd_m, (u32) dstime->bcd_s, (u32) dstime->bcd_D, (u32) dstime->bcd_M, (u32) dstime->bcd_Y, + DrawStringF(MAIN_SCREEN, x, y + str_height - 28, COLOR_STD_FONT, COLOR_STD_BG, "YYYY-MM-DD hh:mm:ss"); + DrawStringF(MAIN_SCREEN, x, y + str_height - 18, COLOR_STD_FONT, COLOR_STD_BG, "20%02lX-%02lX-%02lX %02lX:%02lX:%02lX\n %-*.*s^^%-*.*s", + (u32) dstime->bcd_Y, (u32) dstime->bcd_M, (u32) dstime->bcd_D, (u32) dstime->bcd_h, (u32) dstime->bcd_m, (u32) dstime->bcd_s, cursor * 3, cursor * 3, "", 17 - 2 - (cursor * 3), 17 - 2 - (cursor * 3), ""); // user input diff --git a/source/godmode.c b/source/godmode.c index e4a36d4..7992000 100644 --- a/source/godmode.c +++ b/source/godmode.c @@ -132,8 +132,8 @@ void GetTimeString(char* timestr, bool forced_update) { get_dstime(&dstime); timer = timer_start(); } - if (timestr) snprintf(timestr, 31, "%02lX/%02lX/%02lX %02lX:%02lX", - (u32) dstime.bcd_D, (u32) dstime.bcd_M, (u32) dstime.bcd_Y, (u32) dstime.bcd_h, (u32) dstime.bcd_m); + if (timestr) snprintf(timestr, 31, "20%02lX-%02lX-%02lX %02lX:%02lX", + (u32) dstime.bcd_Y, (u32) dstime.bcd_M, (u32) dstime.bcd_D, (u32) dstime.bcd_h, (u32) dstime.bcd_m); } void DrawUserInterface(const char* curr_path, DirEntry* curr_entry, DirStruct* clipboard, u32 curr_pane) { @@ -1480,7 +1480,7 @@ u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboar if (multi > 0) optionstr[multi - 1] = "Switch EmuNAND"; if (bsupport > 0) optionstr[bsupport - 1] = "Build support files"; if (hsrestore > 0) optionstr[hsrestore - 1] = "Restore H&S"; - if (clock > 0) optionstr[clock - 1] = "Set RTC clock"; + if (clock > 0) optionstr[clock - 1] = "Set RTC date&time"; if (scripts > 0) optionstr[scripts - 1] = "Scripts..."; int user_select = ShowSelectPrompt(n_opt, optionstr, promptstr); @@ -1565,11 +1565,11 @@ u32 HomeMoreMenu(char* current_path, DirStruct* current_dir, DirStruct* clipboar } else if (user_select == clock) { // RTC clock setter DsTime dstime; get_dstime(&dstime); - if (ShowRtcSetterPrompt(&dstime, "Set RTC time/date")) { + if (ShowRtcSetterPrompt(&dstime, "Set RTC date&time:")) { char timestr[32]; set_dstime(&dstime); GetTimeString(timestr, true); - ShowPrompt(false, "New RTC time/date is:\n%s\n \nHint: HOMEMENU time needs\nmanual adjustment after\nsetting the RTC.", + ShowPrompt(false, "New RTC date&time is:\n%s\n \nHint: HOMEMENU time needs\nmanual adjustment after\nsetting the RTC.", timestr); } return 0;