summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/os_win/os_time.c
blob: 52eb5867fa4747a298084f5580472b2ab745a280 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*-
 * Copyright (c) 2014-2019 MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

#include "wt_internal.h"

/*
 * __wt_epoch_raw --
 *     Return the time since the Epoch as reported by the system.
 */
void
__wt_epoch_raw(WT_SESSION_IMPL *session, struct timespec *tsp)
{
    FILETIME time;
    uint64_t ns100;

    WT_UNUSED(session);

    GetSystemTimeAsFileTime(&time);

    ns100 = (((int64_t)time.dwHighDateTime << 32) + time.dwLowDateTime) - 116444736000000000LL;
    tsp->tv_sec = ns100 / 10000000;
    tsp->tv_nsec = (long)((ns100 % 10000000) * 100);
}

/*
 * __wt_localtime --
 *     Return the current local broken-down time.
 */
int
__wt_localtime(WT_SESSION_IMPL *session, const time_t *timep, struct tm *result)
{
    errno_t err;

    if ((err = localtime_s(result, timep)) == 0)
        return (0);

    WT_RET_MSG(session, err, "localtime_s");
}