Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add localtime #55

Open
wants to merge 1 commit into
base: nxdk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions functions/time/localtime.c

This file was deleted.

47 changes: 47 additions & 0 deletions platform/xbox/functions/time/localtime.c
Original file line number Diff line number Diff line change
@@ -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 <time.h>
#include <timezoneapi.h>

#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( &ltimer );
}

#endif

#ifdef TEST

#include "_PDCLIB_test.h"

int main( void )
{
TESTCASE( NO_TESTDRIVER );
return TEST_RESULTS;
}

#endif