#include <stdio.h>
#include <time.h>
const char* const months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
const char* const weekDays[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
const u16 daysAtStartOfMonthLUT[12] =
{
0 % 7,
31 % 7,
59 % 7,
90 % 7,
120 % 7,
151 % 7,
181 % 7,
212 % 7,
243 % 7,
273 % 7,
304 % 7,
334 % 7
};
static inline bool isLeapYear(int year)
{
return (year%4) == 0 && !((year%100) == 0 && (year%400) != 0);
}
static inline int getDayOfWeek(int day, int month, int year)
{
day += 2*(3-((year/100)%4));
year %= 100;
day += year + (year/4);
day += daysAtStartOfMonthLUT[month] - (isLeapYear(year) && (month <= 1));
return day % 7;
}
int main(int argc, char **argv)
{
printf("\x1b[30;16HPress Start to exit.");
{
time_t unixTime = time(NULL);
struct tm* timeStruct = gmtime((const time_t *)&unixTime);
int hours = timeStruct->tm_hour;
int minutes = timeStruct->tm_min;
int seconds = timeStruct->tm_sec;
int day = timeStruct->tm_mday;
int month = timeStruct->tm_mon;
int year = timeStruct->tm_year +1900;
printf("\x1b[1;1H%02i:%02i:%02i", hours, minutes, seconds);
printf("\n%s %s %i %i", weekDays[getDayOfWeek(day, month, year)], months[month], day, year);
}
return 0;
}
bool aptMainLoop(void)
Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every f...
PrintConsole * consoleInit(gfxScreen_t screen, PrintConsole *console)
Initialise the console.
void gfxSwapBuffers(void)
Updates the configuration of both screens.
void gfxInitDefault(void)
Initializes the LCD framebuffers with default parameters This is equivalent to calling:
@ GFX_TOP
Top screen.
Definition: gfx.h:26
void gfxExit(void)
Deinitializes and frees the LCD framebuffers.
void gfxFlushBuffers(void)
Flushes the data cache for the current framebuffers.
#define gspWaitForVBlank()
Waits for VBlank.
Definition: gspgpu.h:151
@ KEY_START
Start.
Definition: hid.h:15
u32 hidKeysDown(void)
Returns a bitmask of newly pressed buttons, this frame.
void hidScanInput(void)
Scans HID for input data.
uint16_t u16
16-bit unsigned integer
Definition: types.h:22
uint32_t u32
32-bit unsigned integer
Definition: types.h:23