-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLocaltime.cpp
More file actions
38 lines (32 loc) · 944 Bytes
/
Copy pathLocaltime.cpp
File metadata and controls
38 lines (32 loc) · 944 Bytes
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
/*
* Copyright 2002, Log4cpp Project. All rights reserved.
*
* See the COPYING file for the terms of usage and distribution.
*/
#include "Localtime.hh"
#include <log4cpp/Portability.hh>
#include <memory.h>
#include <time.h>
namespace log4cpp {
#if defined(_MSC_VER) && defined(LOG4CPP_HAVE_LOCALTIME_R)
int localtime_tsafe(const ::time_t* time, ::tm* t) {
errno_t lt_res = localtime_s(t, time);
return static_cast<int>(lt_res);
}
#endif
#if !defined(_MSC_VER) && defined(LOG4CPP_HAVE_LOCALTIME_R)
int localtime_tsafe(const ::time_t* time, ::tm* t) {
return (localtime_r(time, t) != NULL ? 0 : -1);
}
#endif
#if !defined(LOG4CPP_HAVE_LOCALTIME_R)
int localtime_tsafe(const ::time_t* time, ::tm* t) {
::tm* tmp = ::localtime(time);
if (tmp == NULL) {
return -1;
}
memcpy(t, tmp, sizeof(::tm));
return 0;
}
#endif
} // namespace log4cpp