Merge pull request #1320 from nathanhitch/master
Add ability to offset ntp by any amount of minutes
This commit is contained in:
commit
93f770888d
@ -336,6 +336,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
|||||||
cantStart = R_FAILED(res) || !isSocURegistered;
|
cantStart = R_FAILED(res) || !isSocURegistered;
|
||||||
|
|
||||||
int utcOffset = 12;
|
int utcOffset = 12;
|
||||||
|
int utcOffsetMinute = 0;
|
||||||
int absOffset;
|
int absOffset;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -344,14 +345,15 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
|||||||
|
|
||||||
absOffset = utcOffset - 12;
|
absOffset = utcOffset - 12;
|
||||||
absOffset = absOffset < 0 ? -absOffset : absOffset;
|
absOffset = absOffset < 0 ? -absOffset : absOffset;
|
||||||
posY = Draw_DrawFormattedString(10, 30, COLOR_WHITE, "Current UTC offset: %c%02d", utcOffset < 12 ? '-' : '+', absOffset);
|
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 offset.\nPress A when done.") + SPACING_Y;
|
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();
|
input = waitInput();
|
||||||
|
|
||||||
if(input & BUTTON_LEFT) utcOffset = (24 + utcOffset - 1) % 24; // ensure utcOffset >= 0
|
if(input & BUTTON_LEFT) utcOffset = (24 + utcOffset - 1) % 24; // ensure utcOffset >= 0
|
||||||
if(input & BUTTON_RIGHT) utcOffset = (utcOffset + 1) % 24;
|
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_FlushFramebuffer();
|
||||||
Draw_Unlock();
|
Draw_Unlock();
|
||||||
}
|
}
|
||||||
@ -371,6 +373,7 @@ void MiscellaneousMenu_SyncTimeDate(void)
|
|||||||
if(R_SUCCEEDED(res))
|
if(R_SUCCEEDED(res))
|
||||||
{
|
{
|
||||||
t += 3600 * utcOffset;
|
t += 3600 * utcOffset;
|
||||||
|
t += 60 * utcOffsetMinute;
|
||||||
gmtime_r(&t, &localt);
|
gmtime_r(&t, &localt);
|
||||||
res = ntpSetTimeDate(&localt);
|
res = ntpSetTimeDate(&localt);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user