]> asedeno.scripts.mit.edu Git - PuTTY.git/blob - windows/wintime.c
first pass
[PuTTY.git] / windows / wintime.c
1 /*
2  * wintime.c - Avoid trouble with time() returning (time_t)-1 on Windows.
3  */
4
5 #include "putty.h"
6 #include <time.h>
7
8 struct tm ltime(void)
9 {
10     SYSTEMTIME st;
11     struct tm tm;
12
13     memset(&tm, 0, sizeof(tm));        /* in case there are any other fields */
14
15     GetLocalTime(&st);
16     tm.tm_sec=st.wSecond;
17     tm.tm_min=st.wMinute;
18     tm.tm_hour=st.wHour;
19     tm.tm_mday=st.wDay;
20     tm.tm_mon=st.wMonth-1;
21     tm.tm_year=(st.wYear>=1900?st.wYear-1900:0);
22     tm.tm_wday=st.wDayOfWeek;
23     tm.tm_yday=-1; /* GetLocalTime doesn't tell us */
24     tm.tm_isdst=0; /* GetLocalTime doesn't tell us */
25     return tm;
26 }