summaryrefslogtreecommitdiff
path: root/src/os_win/os_time.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/os_win/os_time.c')
-rw-r--r--src/os_win/os_time.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/src/os_win/os_time.c b/src/os_win/os_time.c
new file mode 100644
index 00000000000..9967d88259e
--- /dev/null
+++ b/src/os_win/os_time.c
@@ -0,0 +1,63 @@
+/*-
+ * Copyright (c) 2008-2014 WiredTiger, Inc.
+ * All rights reserved.
+ *
+ * See the file LICENSE for redistribution information.
+ */
+
+#include "wt_internal.h"
+
+/*
+ * __wt_seconds --
+ * Return the seconds since the Epoch.
+ */
+int
+__wt_seconds(WT_SESSION_IMPL *session, time_t *timep)
+{
+ struct timespec t;
+
+ WT_RET(__wt_epoch(session, &t));
+
+ *timep = t.tv_sec;
+
+ return (0);
+}
+
+/*
+ * __wt_epoch --
+ * Return the time since the Epoch.
+ */
+int
+__wt_epoch(WT_SESSION_IMPL *session, struct timespec *tsp)
+{
+ WT_DECL_RET;
+ uint64_t ns100;
+
+ FILETIME time;
+ GetSystemTimeAsFileTime(&time);
+
+ ns100 = (((int64_t)time.dwHighDateTime << 32) + time.dwLowDateTime)
+ - 116444736000000000LL;
+ tsp->tv_sec = ns100 / 10000000;
+ tsp->tv_nsec = ns100 * 100;
+
+ return 0;
+}
+
+/*
+ * localtime_r --
+ * Return the current local time
+ */
+ struct tm *
+localtime_r(const time_t * timer, struct tm * result)
+{
+ errno_t err;
+
+ err = localtime_s(timer, result);
+ if (err != 0) {
+ __wt_err(NULL, err, "localtime_s");
+ return NULL;
+ }
+
+ return result;
+}