Nintendo 3DS >> C/C++

Time


參考資訊:
1. libctru doc
2. 3ds-examples

說明:

API
time_t time(time_t *timer)
struct tm *gmtime(const time_t *timer)

main.c

#include <stdio.h>
#include <time.h>
#include <3ds.h>

int main(void)
{
    time_t unixTime = time(NULL);

    gfxInitDefault();
    consoleInit(GFX_TOP, NULL);

    struct tm *timeStruct = gmtime((const time_t *)&unixTime);
    printf("%d/%d/%d %d:%d:%d\n", 
        timeStruct->tm_mon, timeStruct->tm_mday, timeStruct->tm_year + 1900, 
        timeStruct->tm_hour, timeStruct->tm_min, timeStruct->tm_sec);

    gspWaitForVBlank();
    gfxSwapBuffers();
    svcSleepThread(3000000000LL);
    gfxExit();
    return 0;
}

完成


返回上一頁