diff --git a/functions/time/localtime.c b/functions/time/localtime.c deleted file mode 100644 index 91c0618d..00000000 --- a/functions/time/localtime.c +++ /dev/null @@ -1,28 +0,0 @@ -/* localtime( const time_t * ) - - This file is part of the Public Domain C Library (PDCLib). - Permission is granted to use, modify, and / or redistribute at will. -*/ - -#include - -#ifndef REGTEST - -struct tm * localtime( const time_t * timer ) -{ - return NULL; -} - -#endif - -#ifdef TEST - -#include "_PDCLIB_test.h" - -int main( void ) -{ - TESTCASE( NO_TESTDRIVER ); - return TEST_RESULTS; -} - -#endif diff --git a/platform/xbox/functions/time/localtime.c b/platform/xbox/functions/time/localtime.c new file mode 100644 index 00000000..fc09cf3c --- /dev/null +++ b/platform/xbox/functions/time/localtime.c @@ -0,0 +1,47 @@ +/* localtime( const time_t * ) + + This file is part of the Public Domain C Library (PDCLib). + Permission is granted to use, modify, and / or redistribute at will. +*/ + +#include +#include + +#ifndef REGTEST + +struct tm * localtime( const time_t * timer ) +{ + TIME_ZONE_INFORMATION tzinfo; + DWORD tz = GetTimeZoneInformation( &tzinfo ); + + if ( tz == TIME_ZONE_ID_INVALID ) + { + return NULL; + } + if ( tz == TIME_ZONE_ID_STANDARD ) + { + tzinfo.Bias += tzinfo.StandardBias; + } + else if ( tz == TIME_ZONE_ID_DAYLIGHT ) + { + tzinfo.Bias += tzinfo.DaylightBias; + } + + time_t ltimer = *timer - tzinfo.Bias * 60; + + return gmtime( <imer ); +} + +#endif + +#ifdef TEST + +#include "_PDCLIB_test.h" + +int main( void ) +{ + TESTCASE( NO_TESTDRIVER ); + return TEST_RESULTS; +} + +#endif