Skip to content

Commit

Permalink
Add function to get unix system time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Koi-3088 committed Jan 18, 2023
1 parent decfb9d commit 88741e2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
13 changes: 12 additions & 1 deletion sys-botbase/source/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <math.h>
#include "commands.h"
#include "util.h"
#include "time.h"

//Controller:
bool bControllerIsInitialised = false;
Expand Down Expand Up @@ -525,3 +524,15 @@ void sendUsbResponse(USBResponse response)
if (response.size > 0)
usbCommsWrite(response.data, response.size);
}

long getUnixTime()
{
time_t unixTime = 0;
Result tg = timeGetCurrentTime(TimeType_UserSystemClock, (u64*)&unixTime);
if (R_FAILED(tg))
{
fatalThrow(tg);
return -1;
}
return unixTime;
}
1 change: 1 addition & 0 deletions sys-botbase/source/commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ void key(HiddbgKeyboardAutoPilotState* states, u64 sequentialCount);
void clickSequence(char* seq, u8* token);
void dateSkip();
void resetTime();
long getUnixTime();
void sendUsbResponse(USBResponse response);
12 changes: 12 additions & 0 deletions sys-botbase/source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,18 @@ int argmain(int argc, char **argv)

if(!strcmp(argv[0], "resetTime"))
resetTime();

if (!strcmp(argv[0], "getUnixTime"))
{
long time = getUnixTime();
if (usb)
{
response.size = sizeof(long);
response.data = &time;
sendUsbResponse(response);
}
else printf("%016lX\n", time);
}

return 0;
}
Expand Down

0 comments on commit 88741e2

Please sign in to comment.