mirror of
https://github.com/switchbrew/switch-examples.git
synced 2025-06-20 21:12:38 +02:00
time: display local time
This commit is contained in:
parent
399aa26c6e
commit
5e36dc2902
@ -1,5 +1,6 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <switch.h>
|
||||
@ -20,6 +21,7 @@ int main(int argc, char **argv)
|
||||
padInitializeDefault(&pad);
|
||||
|
||||
printf("\x1b[16;16HPress PLUS to exit.");
|
||||
printf("\x1b[17;16HTZ=%s\n", getenv("TZ"));
|
||||
|
||||
// Main loop
|
||||
while(appletMainLoop())
|
||||
@ -34,7 +36,7 @@ int main(int argc, char **argv)
|
||||
|
||||
//Print current time
|
||||
time_t unixTime = time(NULL);
|
||||
struct tm* timeStruct = gmtime((const time_t *)&unixTime);//Gets UTC time. If you want local-time use localtime().
|
||||
struct tm* timeStruct = localtime((const time_t *)&unixTime); // Gets local time. If you want UTC use gmtime().
|
||||
|
||||
int hours = timeStruct->tm_hour;
|
||||
int minutes = timeStruct->tm_min;
|
||||
|
Loading…
Reference in New Issue
Block a user