Merge pull request #1320 from nathanhitch/master

Add ability to offset ntp by any amount of minutes
This commit is contained in:
TuxSH 2019-11-05 00:13:22 +00:00 committed by GitHub
commit 93f770888d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -336,6 +336,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
cantStart = R_FAILED(res) || !isSocURegistered;
int utcOffset = 12;
int utcOffsetMinute = 0;
int absOffset;
do
{
@ -344,14 +345,15 @@ void MiscellaneousMenu_SyncTimeDate(void)
absOffset = utcOffset - 12;
absOffset = absOffset < 0 ? -absOffset : absOffset;
posY = Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Current UTC offset: %c%02d", utcOffset < 12 ? '-' : '+', absOffset);
posY = Draw_DrawFormattedString(10, posY + SPACING_Y, COLOR_WHITE, "Use DPAD Left/Right to change offset.\nPress A when done.") + SPACING_Y;
posY = Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Current UTC offset: %c%02d%02d", utcOffset < 12 ? '-' : '+', absOffset, utcOffsetMinute);
posY = Draw_DrawFormattedString(10, posY + SPACING_Y, COLOR_WHITE, "Use DPAD Left/Right to change hour offset.\nUse DPAD Up/Down to change minute offset.\nPress A when done.") + SPACING_Y;
input = waitInput();
if(input & BUTTON_LEFT) utcOffset = (24 + utcOffset - 1) % 24; // ensure utcOffset >= 0
if(input & BUTTON_RIGHT) utcOffset = (utcOffset + 1) % 24;
if(input & BUTTON_UP) utcOffsetMinute = (utcOffsetMinute + 1) % 60;
if(input & BUTTON_DOWN) utcOffsetMinute = (60 + utcOffsetMinute - 1) % 60;
Draw_FlushFramebuffer();
Draw_Unlock();
}
@ -371,6 +373,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
if(R_SUCCEEDED(res))
{
t += 3600 * utcOffset;
t += 60 * utcOffsetMinute;
gmtime_r(&t, &localt);
res = ntpSetTimeDate(&localt);
}