This commit is contained in:
gabime
2014-12-21 02:47:04 +02:00
parent fa677017a6
commit 40a55b8e34
38 changed files with 2995 additions and 2995 deletions

View File

@@ -44,19 +44,19 @@ inline std::tm localtime(const std::time_t &time_tt)
{
#ifdef _WIN32
std::tm tm;
localtime_s(&tm, &time_tt);
std::tm tm;
localtime_s(&tm, &time_tt);
#else
std::tm tm;
localtime_r(&time_tt, &tm);
std::tm tm;
localtime_r(&time_tt, &tm);
#endif
return tm;
return tm;
}
inline std::tm localtime()
{
std::time_t now_t = time(0);
return localtime(now_t);
std::time_t now_t = time(0);
return localtime(now_t);
}
@@ -64,57 +64,57 @@ inline std::tm gmtime(const std::time_t &time_tt)
{
#ifdef _WIN32
std::tm tm;
gmtime_s(&tm, &time_tt);
std::tm tm;
gmtime_s(&tm, &time_tt);
#else
std::tm tm;
gmtime_r(&time_tt, &tm);
std::tm tm;
gmtime_r(&time_tt, &tm);
#endif
return tm;
return tm;
}
inline std::tm gmtime()
{
std::time_t now_t = time(0);
return gmtime(now_t);
std::time_t now_t = time(0);
return gmtime(now_t);
}
inline bool operator==(const std::tm& tm1, const std::tm& tm2)
{
return (tm1.tm_sec == tm2.tm_sec &&
tm1.tm_min == tm2.tm_min &&
tm1.tm_hour == tm2.tm_hour &&
tm1.tm_mday == tm2.tm_mday &&
tm1.tm_mon == tm2.tm_mon &&
tm1.tm_year == tm2.tm_year &&
tm1.tm_isdst == tm2.tm_isdst);
return (tm1.tm_sec == tm2.tm_sec &&
tm1.tm_min == tm2.tm_min &&
tm1.tm_hour == tm2.tm_hour &&
tm1.tm_mday == tm2.tm_mday &&
tm1.tm_mon == tm2.tm_mon &&
tm1.tm_year == tm2.tm_year &&
tm1.tm_isdst == tm2.tm_isdst);
}
inline bool operator!=(const std::tm& tm1, const std::tm& tm2)
{
return !(tm1 == tm2);
return !(tm1 == tm2);
}
#ifdef _WIN32
inline const char* eol()
{
return "\r\n";
return "\r\n";
}
#else
constexpr inline const char* eol()
{
return "\n";
return "\n";
}
#endif
#ifdef _WIN32
inline unsigned short eol_size()
{
return 2;
return 2;
}
#else
constexpr inline unsigned short eol_size()
{
return 1;
return 1;
}
#endif
@@ -122,11 +122,11 @@ constexpr inline unsigned short eol_size()
inline int fopen_s(FILE** fp, const std::string& filename, const char* mode)
{
#ifdef _WIN32
*fp = _fsopen((filename.c_str()), mode, _SH_DENYWR);
return *fp == nullptr;
*fp = _fsopen((filename.c_str()), mode, _SH_DENYWR);
return *fp == nullptr;
#else
*fp = fopen((filename.c_str()), mode);
return *fp == nullptr;
*fp = fopen((filename.c_str()), mode);
return *fp == nullptr;
#endif
@@ -137,14 +137,14 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
{
#ifdef _WIN32
(void)tm; // avoid unused param warning
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
if (!rv)
return -1;
return -1 * (tzinfo.Bias + tzinfo.DaylightBias);
(void)tm; // avoid unused param warning
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
auto rv = GetDynamicTimeZoneInformation(&tzinfo);
if (!rv)
return -1;
return -1 * (tzinfo.Bias + tzinfo.DaylightBias);
#else
return static_cast<int>(tm.tm_gmtoff / 60);
return static_cast<int>(tm.tm_gmtoff / 60);
#endif
}