00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef NLOCALTIME_H
00023 #define NLOCALTIME_H
00024
00031
00032
00033
00034 #undef n_localtime
00035 #if defined(__WIN32) && defined (_MSC_VER)
00036 #define n_localtime(m_time, tmpTime) \
00037 { \
00038 if (localtime_s(const_cast<tm *>(&m_time), &tmpTime) != 0) { \
00039 NString msg; \
00040 NWarning::print() << \
00041 msg.arg("Unable to obtain current date/time: %s", nerror(errno));\
00042 } \
00043 }
00044 #elif defined(__WIN32) && defined (__GNUC__)
00045 #define n_localtime(m_time, tmpTime) \
00046 {\
00047 struct tm *my_tmp = localtime(&tmpTime); \
00048 if (my_tmp) { \
00049 NString msg; \
00050 memcpy((void *)&m_time, my_tmp, sizeof(m_time)); \
00051 NWarning::print() << msg.arg("Unable to obtain current date/time: %s", nerror(errno));\
00052 } \
00053 }
00054 #else
00055 #define n_localtime(m_time, tmpTime) \
00056 { \
00057 if (!localtime_r(&tmpTime, const_cast<tm *>(&m_time))) { \
00058 NString msg; \
00059 NWarning::print() << \
00060 msg.arg("Unable to obtain current date/time: %s", nerror(errno));\
00061 } \
00062 }
00063 #endif
00064
00065 #endif // NLOCALTIME_H_