ltime.c 668 B

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