| /* 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> |
| |
| 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); |
| if(status < 0) { |
| __set_errno_from_ntstatus(status); |
| return NULL; |
| } |
| // tzi.Bias is minute based |
| time_t lt = *timep - tzi.Bias * 60; |
| return gmtime_r(<, tp) ? tp : NULL; |
| } |
| |
| struct tm *localtime(const time_t *timep) { |
| static struct tm buffer; |
| return localtime_r(timep, &buffer); |
| } |