From 88741e2cbd1f7552ec7778740a3523989ca863c1 Mon Sep 17 00:00:00 2001 From: Koi Date: Tue, 17 Jan 2023 18:34:51 -0600 Subject: [PATCH] Add function to get unix system time. --- sys-botbase/source/commands.c | 13 ++++++++++++- sys-botbase/source/commands.h | 1 + sys-botbase/source/main.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/sys-botbase/source/commands.c b/sys-botbase/source/commands.c index 257509a..9104991 100644 --- a/sys-botbase/source/commands.c +++ b/sys-botbase/source/commands.c @@ -6,7 +6,6 @@ #include #include "commands.h" #include "util.h" -#include "time.h" //Controller: bool bControllerIsInitialised = false; @@ -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; +} diff --git a/sys-botbase/source/commands.h b/sys-botbase/source/commands.h index 7789d21..f70247b 100644 --- a/sys-botbase/source/commands.h +++ b/sys-botbase/source/commands.h @@ -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); diff --git a/sys-botbase/source/main.c b/sys-botbase/source/main.c index 3ffccaa..d142522 100644 --- a/sys-botbase/source/main.c +++ b/sys-botbase/source/main.c @@ -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; }