File: ltime.c

package info (click to toggle)
putty 0.83-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,216 kB
  • sloc: ansic: 148,476; python: 8,466; perl: 1,830; makefile: 128; sh: 117
file content (27 lines) | stat: -rw-r--r-- 641 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
 * Implementation of ltime() that avoids trouble with time() returning
 * (time_t)-1 on Windows.
 */

#include "putty.h"
#include <time.h>

struct tm ltime(void)
{
    SYSTEMTIME st;
    struct tm tm;

    memset(&tm, 0, sizeof(tm));        /* in case there are any other fields */

    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;
}