diff options
Diffstat (limited to 'uisimulator/common/time-win32.c')
-rw-r--r-- | uisimulator/common/time-win32.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/uisimulator/common/time-win32.c b/uisimulator/common/time-win32.c new file mode 100644 index 0000000000..1de69c35e6 --- /dev/null +++ b/uisimulator/common/time-win32.c | |||
@@ -0,0 +1,61 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2014 by Michael Sevakis | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #include <time.h> | ||
22 | #include <errno.h> | ||
23 | #include "system.h" | ||
24 | #include "debug.h" | ||
25 | |||
26 | /* These functions we like but Windows doesn't because it implements the | ||
27 | non-"_r" versions with thread-local storage in its multithreaded libs */ | ||
28 | |||
29 | struct tm * localtime_r(const time_t *restrict timer, | ||
30 | struct tm *restrict result) | ||
31 | { | ||
32 | if (!timer || !result) | ||
33 | { | ||
34 | errno = EINVAL; | ||
35 | return NULL; | ||
36 | } | ||
37 | |||
38 | struct tm *tm = localtime(timer); | ||
39 | if (!tm) | ||
40 | return NULL; | ||
41 | |||
42 | *result = *tm; | ||
43 | return result; | ||
44 | } | ||
45 | |||
46 | struct tm * gmtime_r(const time_t *restrict timer, | ||
47 | struct tm *restrict result) | ||
48 | { | ||
49 | if (!timer || !result) | ||
50 | { | ||
51 | errno = EINVAL; | ||
52 | return NULL; | ||
53 | } | ||
54 | |||
55 | struct tm *tm = gmtime(timer); | ||
56 | if (!tm) | ||
57 | return NULL; | ||
58 | |||
59 | *result = *tm; | ||
60 | return result; | ||
61 | } | ||