blob: b72962c089198c88f15e5bb37e37a7389013c8ae [file] [log] [blame] [raw]
/* A part of the Native C Library for Windows NT
Copyright 2007-2015 PC GO Ld.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*/
#include <time.h>
#include <errno.h>
#include <windows.h>
#include <nt.h>
#include <stdio.h>
struct tm *localtime_r(const time_t *timep, struct tm *tp) {
if(!timep) {
errno = EINVAL;
return NULL;
}
TIME_ZONE_INFORMATION tzi;
long int status = RtlQueryTimeZoneInformation(&tzi);
//printf("nativelibc debug: status = 0x%lx\n", status);
if(status < 0) {
__set_errno_from_ntstatus(status);
return NULL;
}
if(!gmtime_r(timep, tp)) return NULL;
// tzi.Bias is minute based
tp->tm_hour -= tzi.Bias / 60;
tp->tm_min -= tzi.Bias % 60;
return tp;
}
struct tm *localtime(const time_t *timep) {
static struct tm buffer;
return localtime_r(timep, &buffer);
}