Last active
February 28, 2019 20:01
-
-
Save rw-r-r-0644/614fba631b3e7f01d4d98f1e0e17d5ab to your computer and use it in GitHub Desktop.
RE of some coreinit functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <wut.h> | |
/* 32 bit unix time_t */ | |
typedef uint32_t time32_t; | |
/* coreinit: convert COS time to POSIX time */ | |
time32_t __OSCalendarTimeToPOSIXTime(OSCalendarTime *td) | |
{ | |
/* compute number of days to epoch */ | |
uint32_t epoch_days = (1970 * 365) + GetLeapDays(1970); | |
/* compute number of days to this year */ | |
uint32_t days = (td->tm_year * 365) + GetLeapDays(td->tm_year); | |
days += GetYearDays(td->tm_year, td->tm_mon); | |
days += td->tm_mday - 1; | |
/* compute posix time */ | |
time32_t unix_time = (days - epoch_days) * 86400; | |
unix_time += td->tm_hour * 3600; | |
unix_time += td->tm_min * 60; | |
unix_time += td->tm_sec; | |
return unix_time; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment