Improve cross platform support.

Make validate work for C++11 because the library supports it.
Fix an unused variable mistake i made earlier.
Make constructor public, seems it should be. Possible compiler bug?
This commit is contained in:
gm 2016-06-03 21:10:53 +12:00 committed by Howard Hinnant
parent bf505cc66a
commit 7e66cb2e83
3 changed files with 12 additions and 12 deletions

View File

@ -101,14 +101,14 @@ tzmain()
{
std::cout << name << '\n';
auto z = locate_zone(name);
auto begin = sys_days(jan/1/year::min()) + 0s;
auto end = sys_days(jan/1/2035) + 0s;
auto begin = sys_days(jan/1/year::min()) + seconds{0};
auto end = sys_days(jan/1/2035) + seconds{0};
auto info = z->get_info(begin);
std::cout << "Initially: ";
if (info.offset >= 0s)
if (info.offset >= seconds{0})
std::cout << '+';
std::cout << make_time(info.offset);
if (info.save == 0min)
if (info.save == minutes{0})
std::cout << " standard ";
else
std::cout << " daylight ";
@ -128,10 +128,10 @@ tzmain()
auto ymd = year_month_day(dp);
auto time = make_time(begin - dp);
std::cout << ymd << ' ' << time << "Z ";
if (info.offset >= 0s)
if (info.offset >= seconds{0})
std::cout << '+';
std::cout << make_time(info.offset);
if (info.save == 0min)
if (info.save == minutes{0})
std::cout << " standard ";
else
std::cout << " daylight ";

3
tz.cpp
View File

@ -126,7 +126,7 @@ CONSTDATA auto max_day = date::dec/31;
namespace detail
{
class undocumented {explicit undocumented() = default;};
struct undocumented {explicit undocumented() = default;};
}
#ifndef _MSC_VER
@ -460,7 +460,6 @@ load_timezone_mappings_from_csv_file(const std::string& input_path)
sis.clear();
sis.str(linebuf);
char ch;
read_field_quote();
std::getline(sis, zm.other, '\"');
read_field_delim();

9
tz.h
View File

@ -95,6 +95,7 @@ static_assert(HAS_REMOTE_API == 0 ? AUTO_DOWNLOAD == 0 : true,
# include <memory>
# include <mutex>
#endif
#include <time.h>
namespace date
{
@ -103,7 +104,7 @@ enum class choose {earliest, latest};
namespace detail
{
class undocumented;
struct undocumented;
}
class nonexistent_local_time
@ -1431,10 +1432,10 @@ parse(std::basic_istream<CharT, Traits>& is,
f.get(is, 0, is, err, &tm, b, e);
if ((err & ios_base::failbit) == 0)
{
#ifndef _MSC_VER
auto tt = timegm(&tm);
#else
#if _WIN32
auto tt = _mkgmtime(&tm);
#else
auto tt = timegm(&tm);
#endif
tp = floor<Duration>(system_clock::from_time_t(tt) + subseconds);
abbrev = std::move(temp_abbrev);