1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 18:07:59 +00:00
putty-source/windows/wintime.c
Owen Dunn 06434ffc71 New function ltime() returns a struct tm of the current local time.
Fixes crashes when time() returns (time_t)-1 on Windows by using the
Win32 GetLocalTime() function.  (The Unix implementation still just 
uses time() and localtime().)

[originally from svn r5086]
2005-01-09 14:27:48 +00:00

21 lines
455 B
C

#include "putty.h"
#include <time.h>
struct tm ltime(void)
{
SYSTEMTIME st;
struct tm tm;
GetLocalTime(&st);
tm.tm_sec=st.wSecond;
tm.tm_min=st.wMinute;
tm.tm_hour=st.wHour;
tm.tm_mday=st.wDay;
tm.tm_mon=st.wMonth-1;
tm.tm_year=(st.wYear>=1900?st.wYear-1900:0);
tm.tm_wday=st.wDayOfWeek;
tm.tm_yday=-1; /* GetLocalTime doesn't tell us */
tm.tm_isdst=0; /* GetLocalTime doesn't tell us */
return tm;
}