mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-03 04:34:26 +02:00
Prevent warnings when using -Wundef flag
This commit is contained in:
8
date.h
8
date.h
@@ -957,7 +957,7 @@ trunc(const std::chrono::duration<Rep, Period>& d)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// VS Update 2 provides floor, ceil, round, abs in chrono.
|
// VS Update 2 provides floor, ceil, round, abs in chrono.
|
||||||
#if _MSC_FULL_VER < 190023918
|
#if !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||||
|
|
||||||
// round down
|
// round down
|
||||||
template <class To, class Rep, class Period>
|
template <class To, class Rep, class Period>
|
||||||
@@ -1054,14 +1054,14 @@ ceil(const std::chrono::time_point<Clock, FromDuration>& tp)
|
|||||||
return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
|
return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // _MSC_FULL_VER < 190023918
|
#else // !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||||
|
|
||||||
using std::chrono::floor;
|
using std::chrono::floor;
|
||||||
using std::chrono::ceil;
|
using std::chrono::ceil;
|
||||||
using std::chrono::round;
|
using std::chrono::round;
|
||||||
using std::chrono::abs;
|
using std::chrono::abs;
|
||||||
|
|
||||||
#endif // _MSC_FULL_VER < 190023918
|
#endif // !defined(_MSC_FULL_VER) || _MSC_FULL_VER < 190023918
|
||||||
|
|
||||||
// trunc towards zero
|
// trunc towards zero
|
||||||
template <class To, class Clock, class FromDuration>
|
template <class To, class Clock, class FromDuration>
|
||||||
@@ -3829,7 +3829,7 @@ class time_of_day
|
|||||||
{
|
{
|
||||||
using base = detail::time_of_day_storage<Duration>;
|
using base = detail::time_of_day_storage<Duration>;
|
||||||
public:
|
public:
|
||||||
#if !(_MSC_VER && !defined(__clang__))
|
#if !(defined(_MSC_VER) && !defined(__clang__))
|
||||||
// C++11
|
// C++11
|
||||||
using base::base;
|
using base::base;
|
||||||
#else
|
#else
|
||||||
|
40
tz.cpp
40
tz.cpp
@@ -25,7 +25,7 @@
|
|||||||
// been invented (that woud involve another several millennia of evolution).
|
// been invented (that woud involve another several millennia of evolution).
|
||||||
// We did not mean to shout.
|
// We did not mean to shout.
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
// Windows.h will be included directly and indirectly (e.g. by curl).
|
// Windows.h will be included directly and indirectly (e.g. by curl).
|
||||||
// We need to define these macros to prevent Windows.h bringing in
|
// We need to define these macros to prevent Windows.h bringing in
|
||||||
// more than we need and do it eearly so Windows.h doesn't get included
|
// more than we need and do it eearly so Windows.h doesn't get included
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
// https://msdn.microsoft.com/en-nz/library/windows/desktop/aa383745(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-nz/library/windows/desktop/aa383745(v=vs.85).aspx
|
||||||
// that "If you define NTDDI_VERSION, you must also define _WIN32_WINNT."
|
// that "If you define NTDDI_VERSION, you must also define _WIN32_WINNT."
|
||||||
// So we declare we require Vista or greater.
|
// So we declare we require Vista or greater.
|
||||||
#if __MINGW32__
|
#ifdef __MINGW32__
|
||||||
|
|
||||||
#ifndef NTDDI_VERSION
|
#ifndef NTDDI_VERSION
|
||||||
#define NTDDI_VERSION 0x06000000
|
#define NTDDI_VERSION 0x06000000
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
// the current time zone. On Win32 Windows.h provides a means to do it.
|
// the current time zone. On Win32 Windows.h provides a means to do it.
|
||||||
// gcc/mingw supports unistd.h on Win32 but MSVC does not.
|
// gcc/mingw supports unistd.h on Win32 but MSVC does not.
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# include <io.h> // _unlink etc.
|
# include <io.h> // _unlink etc.
|
||||||
# include <ShlObj.h> // CoTaskFree, ShGetKnownFolderPath etc.
|
# include <ShlObj.h> // CoTaskFree, ShGetKnownFolderPath etc.
|
||||||
# if HAS_REMOTE_API
|
# if HAS_REMOTE_API
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
#include <curl/curl.h>
|
#include <curl/curl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
static CONSTDATA char folder_delimiter = '\\';
|
static CONSTDATA char folder_delimiter = '\\';
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
@@ -197,7 +197,7 @@ namespace date
|
|||||||
|
|
||||||
static std::string get_install()
|
static std::string get_install()
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
std::string install = get_download_folder();
|
std::string install = get_download_folder();
|
||||||
install += folder_delimiter;
|
install += folder_delimiter;
|
||||||
install += "tzdata";
|
install += "tzdata";
|
||||||
@@ -243,7 +243,7 @@ struct undocumented {explicit undocumented() = default;};
|
|||||||
static_assert(min_year <= max_year, "Configuration error");
|
static_assert(min_year <= max_year, "Configuration error");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
|
|
||||||
namespace // Put types in an anonymous name space.
|
namespace // Put types in an anonymous name space.
|
||||||
{
|
{
|
||||||
@@ -2167,7 +2167,7 @@ static
|
|||||||
bool
|
bool
|
||||||
file_exists(const std::string& filename)
|
file_exists(const std::string& filename)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
return ::_access(filename.c_str(), 0) == 0;
|
return ::_access(filename.c_str(), 0) == 0;
|
||||||
#else
|
#else
|
||||||
return ::access(filename.c_str(), F_OK) == 0;
|
return ::access(filename.c_str(), F_OK) == 0;
|
||||||
@@ -2283,7 +2283,7 @@ remote_download(const std::string& version)
|
|||||||
".tar.gz";
|
".tar.gz";
|
||||||
bool result = download_to_file(url, get_download_gz_file(version),
|
bool result = download_to_file(url, get_download_gz_file(version),
|
||||||
download_file_options::binary);
|
download_file_options::binary);
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
if (result)
|
if (result)
|
||||||
{
|
{
|
||||||
auto mapping_file = get_download_mapping_file(version);
|
auto mapping_file = get_download_mapping_file(version);
|
||||||
@@ -2306,7 +2306,7 @@ static
|
|||||||
bool
|
bool
|
||||||
remove_folder_and_subfolders(const std::string& folder)
|
remove_folder_and_subfolders(const std::string& folder)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# if USE_SHELL_API
|
# if USE_SHELL_API
|
||||||
// Delete the folder contents by deleting the folder.
|
// Delete the folder contents by deleting the folder.
|
||||||
std::string cmd = "rd /s /q \"";
|
std::string cmd = "rd /s /q \"";
|
||||||
@@ -2385,7 +2385,7 @@ static
|
|||||||
bool
|
bool
|
||||||
make_directory(const std::string& folder)
|
make_directory(const std::string& folder)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# if USE_SHELL_API
|
# if USE_SHELL_API
|
||||||
// Re-create the folder.
|
// Re-create the folder.
|
||||||
std::string cmd = "mkdir \"";
|
std::string cmd = "mkdir \"";
|
||||||
@@ -2408,7 +2408,7 @@ static
|
|||||||
bool
|
bool
|
||||||
delete_file(const std::string& file)
|
delete_file(const std::string& file)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# if USE_SHELL_API
|
# if USE_SHELL_API
|
||||||
std::string cmd = "del \"";
|
std::string cmd = "del \"";
|
||||||
cmd += file;
|
cmd += file;
|
||||||
@@ -2426,13 +2426,13 @@ delete_file(const std::string& file)
|
|||||||
#endif // !WIN32
|
#endif // !WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
|
|
||||||
static
|
static
|
||||||
bool
|
bool
|
||||||
move_file(const std::string& from, const std::string& to)
|
move_file(const std::string& from, const std::string& to)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# if USE_SHELL_API
|
# if USE_SHELL_API
|
||||||
std::string cmd = "move \"";
|
std::string cmd = "move \"";
|
||||||
cmd += from;
|
cmd += from;
|
||||||
@@ -2454,7 +2454,7 @@ move_file(const std::string& from, const std::string& to)
|
|||||||
|
|
||||||
#endif // TIMEZONE_MAPPING
|
#endif // TIMEZONE_MAPPING
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
// Note folder can and usually does contain spaces.
|
// Note folder can and usually does contain spaces.
|
||||||
static
|
static
|
||||||
@@ -2684,7 +2684,7 @@ remote_install(const std::string& version)
|
|||||||
{
|
{
|
||||||
if (extract_gz_file(version, gz_file, install))
|
if (extract_gz_file(version, gz_file, install))
|
||||||
success = true;
|
success = true;
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
auto mapping_file_source = get_download_mapping_file(version);
|
auto mapping_file_source = get_download_mapping_file(version);
|
||||||
auto mapping_file_dest = install;
|
auto mapping_file_dest = install;
|
||||||
mapping_file_dest += folder_delimiter;
|
mapping_file_dest += folder_delimiter;
|
||||||
@@ -2830,7 +2830,7 @@ init_tzdb()
|
|||||||
std::sort(db.leaps.begin(), db.leaps.end());
|
std::sort(db.leaps.begin(), db.leaps.end());
|
||||||
db.leaps.shrink_to_fit();
|
db.leaps.shrink_to_fit();
|
||||||
|
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
std::string mapping_file = path + "windowsZones.xml";
|
std::string mapping_file = path + "windowsZones.xml";
|
||||||
db.mappings = load_timezone_mappings_from_xml_file(mapping_file);
|
db.mappings = load_timezone_mappings_from_xml_file(mapping_file);
|
||||||
sort_zone_mappings(db.mappings);
|
sort_zone_mappings(db.mappings);
|
||||||
@@ -2983,12 +2983,12 @@ operator<<(std::ostream& os, const local_info& r)
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
const time_zone*
|
const time_zone*
|
||||||
current_zone()
|
current_zone()
|
||||||
{
|
{
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
TIME_ZONE_INFORMATION tzi{};
|
TIME_ZONE_INFORMATION tzi{};
|
||||||
DWORD tz_result = ::GetTimeZoneInformation(&tzi);
|
DWORD tz_result = ::GetTimeZoneInformation(&tzi);
|
||||||
if (tz_result == TIME_ZONE_ID_INVALID)
|
if (tz_result == TIME_ZONE_ID_INVALID)
|
||||||
@@ -3104,7 +3104,7 @@ current_zone()
|
|||||||
|
|
||||||
#endif // !WIN32
|
#endif // !WIN32
|
||||||
|
|
||||||
#if TZ_TEST && TIMEZONE_MAPPING
|
#if defined(TZ_TEST) && defined(TIMEZONE_MAPPING)
|
||||||
|
|
||||||
const time_zone*
|
const time_zone*
|
||||||
locate_native_zone(const std::string& native_tz_name)
|
locate_native_zone(const std::string& native_tz_name)
|
||||||
|
20
tz.h
20
tz.h
@@ -40,12 +40,12 @@
|
|||||||
// required. On Windows, the names are never "Standard" so mapping is always required.
|
// required. On Windows, the names are never "Standard" so mapping is always required.
|
||||||
// Technically any OS may use the mapping process but currently only Windows does use it.
|
// Technically any OS may use the mapping process but currently only Windows does use it.
|
||||||
|
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
# ifndef TIMEZONE_MAPPING
|
# ifndef TIMEZONE_MAPPING
|
||||||
# define TIMEZONE_MAPPING 1
|
# define TIMEZONE_MAPPING 1
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# if TIMEZONE_MAPPING
|
# ifdef TIMEZONE_MAPPING
|
||||||
# error "Timezone mapping is not required or not implemented for this platform."
|
# error "Timezone mapping is not required or not implemented for this platform."
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAS_REMOTE_API
|
#ifndef HAS_REMOTE_API
|
||||||
# if _WIN32
|
# ifdef _WIN32
|
||||||
# define HAS_REMOTE_API 0
|
# define HAS_REMOTE_API 0
|
||||||
# else
|
# else
|
||||||
# define HAS_REMOTE_API 1
|
# define HAS_REMOTE_API 1
|
||||||
@@ -69,6 +69,10 @@
|
|||||||
static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
|
static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
|
||||||
"AUTO_DOWNLOAD can not be turned on without HAS_REMOTE_API");
|
"AUTO_DOWNLOAD can not be turned on without HAS_REMOTE_API");
|
||||||
|
|
||||||
|
#ifndef USE_SHELL_API
|
||||||
|
# define USE_SHELL_API 0
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "date.h"
|
#include "date.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -625,7 +629,7 @@ operator>=(const sys_time<Duration>& x, const leap& y)
|
|||||||
return !(x < y);
|
return !(x < y);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
@@ -677,7 +681,7 @@ struct TZ_DB
|
|||||||
std::vector<link> links;
|
std::vector<link> links;
|
||||||
std::vector<leap> leaps;
|
std::vector<leap> leaps;
|
||||||
std::vector<Rule> rules;
|
std::vector<Rule> rules;
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
// TODO! These need some protection.
|
// TODO! These need some protection.
|
||||||
std::vector<detail::timezone_mapping> mappings;
|
std::vector<detail::timezone_mapping> mappings;
|
||||||
std::vector<detail::timezone_info> native_zones;
|
std::vector<detail::timezone_info> native_zones;
|
||||||
@@ -695,7 +699,7 @@ struct TZ_DB
|
|||||||
links(std::move(src.links)),
|
links(std::move(src.links)),
|
||||||
leaps(std::move(src.leaps)),
|
leaps(std::move(src.leaps)),
|
||||||
rules(std::move(src.rules))
|
rules(std::move(src.rules))
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
,
|
,
|
||||||
mappings(std::move(src.mappings)),
|
mappings(std::move(src.mappings)),
|
||||||
native_zones(std::move(src.native_zones))
|
native_zones(std::move(src.native_zones))
|
||||||
@@ -709,7 +713,7 @@ struct TZ_DB
|
|||||||
links = std::move(src.links);
|
links = std::move(src.links);
|
||||||
leaps = std::move(src.leaps);
|
leaps = std::move(src.leaps);
|
||||||
rules = std::move(src.rules);
|
rules = std::move(src.rules);
|
||||||
#if TIMEZONE_MAPPING
|
#ifdef TIMEZONE_MAPPING
|
||||||
mappings = std::move(src.mappings);
|
mappings = std::move(src.mappings);
|
||||||
native_zones = std::move(src.native_zones);
|
native_zones = std::move(src.native_zones);
|
||||||
#endif
|
#endif
|
||||||
@@ -1677,7 +1681,7 @@ parse(std::basic_istream<CharT, Traits>& is,
|
|||||||
f.get(is, 0, is, err, &tm, b, e);
|
f.get(is, 0, is, err, &tm, b, e);
|
||||||
if ((err & ios_base::failbit) == 0)
|
if ((err & ios_base::failbit) == 0)
|
||||||
{
|
{
|
||||||
#if _WIN32
|
#ifdef _WIN32
|
||||||
auto tt = _mkgmtime(&tm);
|
auto tt = _mkgmtime(&tm);
|
||||||
#else
|
#else
|
||||||
auto tt = timegm(&tm);
|
auto tt = timegm(&tm);
|
||||||
|
Reference in New Issue
Block a user