mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 17:58:03 +08:00
Add timezone db version and misc cleanup
This commit is contained in:
parent
f6664da11e
commit
5acaffc2b3
18
tz.cpp
18
tz.cpp
@ -84,7 +84,7 @@ namespace date
|
|||||||
#if _WIN32 // TODO: sensible default for all platforms.
|
#if _WIN32 // TODO: sensible default for all platforms.
|
||||||
static std::string install{ "c:\\tzdata" };
|
static std::string install{ "c:\\tzdata" };
|
||||||
#else
|
#else
|
||||||
static std::string install{ "/Users/howardhinnant/Downloads/tzdata2015f" };
|
static std::string install{ "/Users/howardhinnant/Downloads/tzdata2016a" };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static const std::vector<std::string> files =
|
static const std::vector<std::string> files =
|
||||||
@ -1906,6 +1906,22 @@ init_tzdb()
|
|||||||
throw std::runtime_error(msg);
|
throw std::runtime_error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::ifstream infile(path + "Makefile");
|
||||||
|
while (infile)
|
||||||
|
{
|
||||||
|
std::string version;
|
||||||
|
infile >> version;
|
||||||
|
if (version == "VERSION=")
|
||||||
|
{
|
||||||
|
infile >> db.version;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (db.version.empty())
|
||||||
|
throw std::runtime_error("Unable to get Timezone database version");
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto& filename : files)
|
for (const auto& filename : files)
|
||||||
{
|
{
|
||||||
std::ifstream infile(path + filename);
|
std::ifstream infile(path + filename);
|
||||||
|
29
tz.h
29
tz.h
@ -204,7 +204,7 @@ public:
|
|||||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
Zone(Zone&&) = default;
|
Zone(Zone&&) = default;
|
||||||
Zone& operator=(Zone&&) = default;
|
Zone& operator=(Zone&&) = default;
|
||||||
#else
|
#else // defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
Zone(Zone&& src)
|
Zone(Zone&& src)
|
||||||
:
|
:
|
||||||
name_(std::move(src.name_)),
|
name_(std::move(src.name_)),
|
||||||
@ -217,7 +217,7 @@ public:
|
|||||||
zonelets_ = std::move(src.zonelets_);
|
zonelets_ = std::move(src.zonelets_);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
|
|
||||||
explicit Zone(const std::string& s);
|
explicit Zone(const std::string& s);
|
||||||
|
|
||||||
@ -553,35 +553,18 @@ struct timezone_mapping
|
|||||||
std::string type;
|
std::string type;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if 0
|
|
||||||
// This represents the type for the tzi field in the windows registry.
|
|
||||||
// It's TBD if we need this yet.
|
|
||||||
struct TZI
|
|
||||||
{
|
|
||||||
TZI() = default;
|
|
||||||
int Bias;
|
|
||||||
int StandardBias;
|
|
||||||
int DaylightBias;
|
|
||||||
SYSTEMTIME StandardDate;
|
|
||||||
SYSTEMTIME DaylightDate;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct timezone_info
|
struct timezone_info
|
||||||
{
|
{
|
||||||
timezone_info() = default;
|
timezone_info() = default;
|
||||||
std::string timezone_id;
|
std::string timezone_id;
|
||||||
std::string standard_name;
|
std::string standard_name;
|
||||||
#if 0 // TBD
|
|
||||||
std::string display_name;
|
|
||||||
TZI tzi;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif // TIMEZONE_MAPPING
|
||||||
|
|
||||||
struct TZ_DB
|
struct TZ_DB
|
||||||
{
|
{
|
||||||
|
std::string version;
|
||||||
std::vector<Zone> zones;
|
std::vector<Zone> zones;
|
||||||
std::vector<Link> links;
|
std::vector<Link> links;
|
||||||
std::vector<Leap> leaps;
|
std::vector<Leap> leaps;
|
||||||
@ -596,7 +579,7 @@ struct TZ_DB
|
|||||||
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
TZ_DB(TZ_DB&&) = default;
|
TZ_DB(TZ_DB&&) = default;
|
||||||
TZ_DB& operator=(TZ_DB&&) = default;
|
TZ_DB& operator=(TZ_DB&&) = default;
|
||||||
#else
|
#else // defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
TZ_DB(TZ_DB&& src)
|
TZ_DB(TZ_DB&& src)
|
||||||
:
|
:
|
||||||
zones(std::move(src.zones)),
|
zones(std::move(src.zones)),
|
||||||
@ -622,7 +605,7 @@ struct TZ_DB
|
|||||||
#endif
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
|
||||||
};
|
};
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& os, const TZ_DB& db);
|
std::ostream& operator<<(std::ostream& os, const TZ_DB& db);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user