From 7918894e6bf8216fb3e4ccf2d6f641ad4c62ac14 Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Thu, 20 Apr 2017 22:07:43 +0900 Subject: [PATCH] add decl of basic_datetime --- toml/toml.hpp | 78 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/toml/toml.hpp b/toml/toml.hpp index 66dab9e..9c04747 100644 --- a/toml/toml.hpp +++ b/toml/toml.hpp @@ -40,6 +40,48 @@ namespace toml { +template +struct basic_datetime +{ + unsignedT year; + unsignedT month; + unsignedT day; + unsignedT hour; + unsignedT minute; + unsignedT second; + floatT subsecond; + intT offset_hour; + intT offset_minute; + + basic_datetime(intT y, intT m, intT d) + : year(y), month(m), day(d), hour(0), minute(0), second(0), + subsecond(0.), offset_hour(0), offset_minute(0) + {} + basic_datetime(intT h, intT m, intT s, floatT ss) + : year(0), month(0), day(0), hour(h), minute(m), second(s), + subsecond(ss), offset_hour(0), offset_minute(0) + {} + basic_datetime(intT y, intT mth, intT d, + intT h, intT min, intT s, floatT ss) + : year(y), month(mth), day(d), hour(h), minute(min), second(s), + subsecond(ss), offset_hour(0), offset_minute(0) + {} + basic_datetime(intT y, intT mth, intT d, + intT h, intT min, intT s, floatT ss, intT oh, intT om) + : year(y), month(mth), day(d), hour(h), minute(min), second(s), + subsecond(ss), offset_hour(oh), offset_minute(om) + {} + + basic_datetime(const std::chrono::system_clock::time_point& tp); + basic_datetime(std::chrono::system_clock::time_point&& tp); + + operator std::chrono::system_clock::time_point() const; + operator std::time_t() const; + operator std::tm() const; +}; + +typedef basic_datetime Datetime; + class value; using key = std::string; @@ -272,38 +314,6 @@ struct internal_error : public toml::exception }; /* -------------------------------------------------------------------------- */ -// template -// struct basic_datetime -// { -// intT year; -// intT month; -// intT day; -// intT hour; -// intT minite; -// intT second; -// floatT subsecond; -// intT offset_hour; -// intT offset_minute; -// -// basic_datetime(intT y, intT m, intT d); -// basic_datetime(intT h, intT m, intT s, floatT ss); -// basic_datetime(intT y, intT mth, intT d, -// intT h, intT min, intT s, floatT ss); -// basic_datetime(intT y, intT mth, intT d, -// intT h, intT min, intT s, floatT ss, intT oh, intT om); -// -// basic_datetime(const std::chrono::system_clock::time_point& tp); -// basic_datetime(std::chrono::system_clock::time_point&& tp); -// -// operator std::chrono::system_clock::time_point() const; -// operator std::time_t() const; -// operator std::tm() const; -// -// private: -// void validate() -// }; - - template struct value_traits { @@ -1036,5 +1046,9 @@ T get(const toml::value& v) return tmp; } + + + + }// toml #endif// TOML_FOR_MODERN_CPP