wintime.c 644 B

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