forked from HowardHinnant/date
Add from_stream
This commit is contained in:
698
date.h
698
date.h
@@ -3397,9 +3397,8 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const CharT* fmt, fields<Duration>& fds,
|
||||
std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
fields<Duration>& fds, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr);
|
||||
|
||||
// time_of_day
|
||||
@@ -3918,7 +3917,7 @@ public:
|
||||
template <class CharT, class Traits, class Duration>
|
||||
friend
|
||||
void
|
||||
date::parse(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
date::from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
fields<Duration>& fds,
|
||||
std::basic_string<CharT, Traits>* abbrev, std::chrono::minutes* offset);
|
||||
};
|
||||
@@ -4022,7 +4021,7 @@ public:
|
||||
template <class CharT, class Traits, class Duration>
|
||||
friend
|
||||
void
|
||||
date::parse(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
date::from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
fields<Duration>& fds,
|
||||
std::basic_string<CharT, Traits>* abbrev, std::chrono::minutes* offset);
|
||||
};
|
||||
@@ -5016,8 +5015,6 @@ to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||
|
||||
// format
|
||||
|
||||
#ifndef NO_EXPRESSION_SFINAE
|
||||
|
||||
template <class CharT, class Streamable>
|
||||
auto
|
||||
format(const std::locale& loc, const CharT* fmt, const Streamable& tp)
|
||||
@@ -5065,172 +5062,6 @@ format(const std::basic_string<CharT, Traits>& fmt, const Streamable& tp)
|
||||
return os.str();
|
||||
}
|
||||
|
||||
#else // NO_EXPRESSION_SFINAE
|
||||
|
||||
// const CharT* formats
|
||||
|
||||
template <class CharT>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const year_month_day& ymd)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, ymd);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const year_month_day& ymd)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, ymd);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const local_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const local_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const sys_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const sys_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Rep, class Period>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt,
|
||||
const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, d);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Rep, class Period>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, d);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// basic_string formats
|
||||
|
||||
template <class CharT, class Traits>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const year_month_day& ymd)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), ymd);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const year_month_day& ymd)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), ymd);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const local_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const local_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const sys_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const sys_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Rep, class Period>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), d);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Rep, class Period>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt,
|
||||
const std::chrono::duration<Rep, Period>& d)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt.c_str(), d);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
#endif // NO_EXPRESSION_SFINAE
|
||||
|
||||
// parse
|
||||
|
||||
namespace detail
|
||||
@@ -5468,8 +5299,9 @@ read(std::basic_istream<CharT, Traits>& is, rld a0, Args&& ...args)
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* fmt, fields<Duration>& fds,
|
||||
std::basic_string<CharT, Traits>* abbrev, std::chrono::minutes* offset)
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
fields<Duration>& fds, std::basic_string<CharT, Traits>* abbrev,
|
||||
std::chrono::minutes* offset)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
@@ -6367,40 +6199,148 @@ broken:
|
||||
is.setstate(ios_base::failbit);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits>
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
year_month_day& ymd, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
ymd = fds.ymd;
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
sys_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offptr);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
tp = sys_days(fds.ymd) + duration_cast<Duration>(fds.tod.to_duration() - *offptr);
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
local_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
tp = local_days(fds.ymd) + duration_cast<Duration>(fds.tod.to_duration());
|
||||
}
|
||||
|
||||
template <class Rep, class Period, class CharT, class Traits>
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
std::chrono::duration<Rep, Period>& d,
|
||||
std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using Duration = std::chrono::duration<Rep, Period>;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
fields<CT> fds{};
|
||||
from_stream(is, fmt, fds, abbrev, offset);
|
||||
if (!is.fail())
|
||||
d = duration_cast<Duration>(fds.tod.to_duration());
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits = std::char_traits<CharT>>
|
||||
struct parse_manip;
|
||||
struct parse_manip
|
||||
{
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
Parsable& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
Parsable& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<Parsable, CharT, Traits>& x)
|
||||
{
|
||||
from_stream(is, x.format_.c_str(), x.tp_, x.abbrev_, x.offset_);
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT, Traits>::type
|
||||
auto
|
||||
parse(const std::basic_string<CharT, Traits>& format, Parsable& tp)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
|
||||
format.c_str(), tp),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp})
|
||||
{
|
||||
return {format, tp};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT, Traits>::type
|
||||
auto
|
||||
parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
|
||||
format.c_str(), tp, &abbrev),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp, &abbrev})
|
||||
{
|
||||
return {format, tp, &abbrev};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT, Traits>::type
|
||||
auto
|
||||
parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
|
||||
std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
|
||||
format.c_str(), tp, nullptr, &offset),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp, nullptr, &offset})
|
||||
{
|
||||
return {format, tp, nullptr, &offset};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT, Traits>::type
|
||||
auto
|
||||
parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
|
||||
format.c_str(), tp, &abbrev, &offset),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp, &abbrev, &offset})
|
||||
{
|
||||
return {format, tp, &abbrev, &offset};
|
||||
}
|
||||
@@ -6409,416 +6349,48 @@ parse(const std::basic_string<CharT, Traits>& format, Parsable& tp,
|
||||
|
||||
template <class Parsable, class CharT>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT>::type
|
||||
auto
|
||||
parse(const CharT* format, Parsable& tp)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT>&>(), format, tp),
|
||||
parse_manip<Parsable, CharT>{format, tp})
|
||||
{
|
||||
return {format, tp};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT>::type
|
||||
auto
|
||||
parse(const CharT* format, Parsable& tp, std::basic_string<CharT, Traits>& abbrev)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format,
|
||||
tp, &abbrev),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp, &abbrev})
|
||||
{
|
||||
return {format, tp, &abbrev};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT>::type
|
||||
auto
|
||||
parse(const CharT* format, Parsable& tp, std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT>&>(), format,
|
||||
tp, nullptr, &offset),
|
||||
parse_manip<Parsable, CharT>{format, tp, nullptr, &offset})
|
||||
{
|
||||
return {format, tp, nullptr, &offset};
|
||||
}
|
||||
|
||||
template <class Parsable, class CharT, class Traits>
|
||||
inline
|
||||
typename parse_manip<Parsable, CharT>::type
|
||||
auto
|
||||
parse(const CharT* format, Parsable& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset)
|
||||
-> decltype(from_stream(std::declval<std::basic_istream<CharT, Traits>&>(), format,
|
||||
tp, &abbrev, &offset),
|
||||
parse_manip<Parsable, CharT, Traits>{format, tp, &abbrev, &offset})
|
||||
{
|
||||
return {format, tp, &abbrev, &offset};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits>
|
||||
struct parse_manip<year_month_day, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
year_month_day& ymd_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
year_month_day& ymd, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, ymd_(ymd)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
};
|
||||
|
||||
template <class CharT, class Traits>
|
||||
inline
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<year_month_day, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = seconds;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, x.offset_);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.ymd_ = fds.ymd;
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
struct parse_manip<local_time<Duration>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
local_time<Duration>& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
local_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
inline
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<local_time<Duration>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, x.offset_);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.tp_ = local_days(fds.ymd) + duration_cast<Duration>(fds.tod.to_duration());
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
struct parse_manip<sys_time<Duration>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
sys_time<Duration>& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
sys_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<sys_time<Duration>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset{};
|
||||
auto offptr = x.offset_ ? x.offset_ : &offset;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, offptr);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.tp_ = sys_days(fds.ymd) +
|
||||
duration_cast<Duration>(fds.tod.to_duration() - *offptr);
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class Rep, class Period, class CharT, class Traits>
|
||||
struct parse_manip<std::chrono::duration<Rep, Period>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
using Duration = std::chrono::duration<Rep, Period>;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
Duration& d_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format, Duration& d)
|
||||
: format_(std::move(format))
|
||||
, d_(d)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Rep, class Period, class CharT, class Traits>
|
||||
inline
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<std::chrono::duration<Rep, Period>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using Duration = std::chrono::duration<Rep, Period>;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds);
|
||||
if (fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.d_ = duration_cast<Duration>(fds.tod.to_duration());
|
||||
return is;
|
||||
}
|
||||
|
||||
#if 0 // use in >> parse(format, x); instead
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, sys_time<Duration>& tp)
|
||||
{
|
||||
std::chrono::minutes offset{};
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format.c_str(), lt, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, sys_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
std::chrono::minutes offset{};
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format.c_str(), lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, sys_time<Duration>& tp,
|
||||
std::chrono::minutes& offset)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format.c_str(), lt, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, sys_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format.c_str(), lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, sys_time<Duration>& tp,
|
||||
std::chrono::minutes& offset, std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format.c_str(), lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, local_time<Duration>& tp)
|
||||
{
|
||||
detail::parse(is, format.c_str(), tp);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, local_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
detail::parse(is, format.c_str(), tp, &abbrev);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, local_time<Duration>& tp,
|
||||
std::chrono::minutes& offset)
|
||||
{
|
||||
detail::parse(is, format.c_str(), tp, &offset);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, local_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset)
|
||||
{
|
||||
detail::parse(is, format.c_str(), tp, &abbrev, &offset);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is,
|
||||
const std::basic_string<CharT, Traits>& format, local_time<Duration>& tp,
|
||||
std::chrono::minutes& offset, std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
detail::parse(is, format.c_str(), tp, &abbrev, &offset);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format, sys_time<Duration>& tp)
|
||||
{
|
||||
std::chrono::minutes offset{};
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format, lt, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format, sys_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
std::chrono::minutes offset{};
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format, lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format, sys_time<Duration>& tp,
|
||||
std::chrono::minutes& offset)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format, lt, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format, sys_time<Duration>& tp,
|
||||
std::basic_string<CharT, Traits>& abbrev, std::chrono::minutes& offset)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format, lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format, sys_time<Duration>& tp,
|
||||
std::chrono::minutes& offset, std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
local_time<Duration> lt;
|
||||
detail::parse(is, format, lt, &abbrev, &offset);
|
||||
if (!is.fail())
|
||||
tp = sys_time<Duration>{floor<Duration>(lt - offset).time_since_epoch()};
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format,
|
||||
local_time<Duration>& tp)
|
||||
{
|
||||
detail::parse(is, format, tp);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format,
|
||||
local_time<Duration>& tp, std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
detail::parse(is, format, tp, &abbrev);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format,
|
||||
local_time<Duration>& tp, std::chrono::minutes& offset)
|
||||
{
|
||||
detail::parse(is, format, tp, &offset);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format,
|
||||
local_time<Duration>& tp, std::basic_string<CharT, Traits>& abbrev,
|
||||
std::chrono::minutes& offset)
|
||||
{
|
||||
detail::parse(is, format, tp, &abbrev, &offset);
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
inline
|
||||
void
|
||||
parse(std::basic_istream<CharT, Traits>& is, const CharT* format,
|
||||
local_time<Duration>& tp, std::chrono::minutes& offset,
|
||||
std::basic_string<CharT, Traits>& abbrev)
|
||||
{
|
||||
detail::parse(is, format, tp, &abbrev, &offset);
|
||||
}
|
||||
|
||||
#endif // use in >> parse(format, x); instead
|
||||
|
||||
} // namespace date
|
||||
|
||||
#endif // DATE_H
|
||||
|
263
tz.h
263
tz.h
@@ -1159,38 +1159,18 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const utc_time<Duration>& t)
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
struct parse_manip<utc_time<Duration>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
utc_time<Duration>& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
utc_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<utc_time<Duration>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset{};
|
||||
auto offptr = x.offset_ ? x.offset_ : &offset;
|
||||
minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, offptr);
|
||||
from_stream(is, fmt, fds, abbrev, offptr);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
@@ -1198,12 +1178,11 @@ operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
bool is_leap_second = fds.tod.seconds() == seconds{60};
|
||||
if (is_leap_second)
|
||||
fds.tod.seconds() -= seconds{1};
|
||||
x.tp_ = to_utc_time(sys_days(fds.ymd) +
|
||||
tp = to_utc_time(sys_days(fds.ymd) +
|
||||
duration_cast<Duration>(fds.tod.to_duration() - *offptr));
|
||||
if (is_leap_second)
|
||||
x.tp_ += seconds{1};
|
||||
tp += seconds{1};
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
// tai_clock
|
||||
@@ -1291,45 +1270,24 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const tai_time<Duration>& t)
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
struct parse_manip<tai_time<Duration>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
tai_time<Duration>& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
tai_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<tai_time<Duration>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset{};
|
||||
auto offptr = x.offset_ ? x.offset_ : &offset;
|
||||
minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, offptr);
|
||||
from_stream(is, fmt, fds, abbrev, offptr);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.tp_ = tai_time<Duration>{duration_cast<Duration>(
|
||||
tp = tai_time<Duration>{duration_cast<Duration>(
|
||||
(sys_days(fds.ymd) + fds.tod.to_duration() + (sys_days(year{1970}/jan/1) -
|
||||
sys_days(year{1958}/jan/1)) - *offptr).time_since_epoch())};
|
||||
return is;
|
||||
}
|
||||
|
||||
// gps_clock
|
||||
@@ -1417,46 +1375,25 @@ operator<<(std::basic_ostream<CharT, Traits>& os, const gps_time<Duration>& t)
|
||||
}
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
struct parse_manip<gps_time<Duration>, CharT, Traits>
|
||||
{
|
||||
using type = parse_manip;
|
||||
const std::basic_string<CharT, Traits> format_;
|
||||
gps_time<Duration>& tp_;
|
||||
std::basic_string<CharT, Traits>* abbrev_;
|
||||
std::chrono::minutes* offset_;
|
||||
|
||||
public:
|
||||
parse_manip(std::basic_string<CharT, Traits> format,
|
||||
void
|
||||
from_stream(std::basic_istream<CharT, Traits>& is, const CharT* fmt,
|
||||
gps_time<Duration>& tp, std::basic_string<CharT, Traits>* abbrev = nullptr,
|
||||
std::chrono::minutes* offset = nullptr)
|
||||
: format_(std::move(format))
|
||||
, tp_(tp)
|
||||
, abbrev_(abbrev)
|
||||
, offset_(offset)
|
||||
{}
|
||||
|
||||
};
|
||||
|
||||
template <class Duration, class CharT, class Traits>
|
||||
std::basic_istream<CharT, Traits>&
|
||||
operator>>(std::basic_istream<CharT, Traits>& is,
|
||||
const parse_manip<gps_time<Duration>, CharT, Traits>& x)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace std::chrono;
|
||||
using CT = typename common_type<Duration, seconds>::type;
|
||||
minutes offset{};
|
||||
auto offptr = x.offset_ ? x.offset_ : &offset;
|
||||
minutes offset_local{};
|
||||
auto offptr = offset ? offset : &offset_local;
|
||||
fields<CT> fds{};
|
||||
parse(is, x.format_.c_str(), fds, x.abbrev_, offptr);
|
||||
from_stream(is, fmt, fds, abbrev, offptr);
|
||||
if (!fds.ymd.ok())
|
||||
is.setstate(ios::failbit);
|
||||
if (!is.fail())
|
||||
x.tp_ = gps_time<Duration>{duration_cast<Duration>(
|
||||
tp = gps_time<Duration>{duration_cast<Duration>(
|
||||
(sys_days(fds.ymd) + fds.tod.to_duration() -
|
||||
(sys_days(year{1980}/jan/sun[1]) -
|
||||
sys_days(year{1970}/jan/1)) - *offptr).time_since_epoch())};
|
||||
return is;
|
||||
}
|
||||
|
||||
template <class Duration>
|
||||
@@ -1497,168 +1434,6 @@ to_gps_time(const tai_time<Duration>& t) NOEXCEPT
|
||||
(sys_days(year{1980}/jan/sun[1]) - sys_days(year{1958}/jan/1) + seconds{19});
|
||||
}
|
||||
|
||||
#ifdef NO_EXPRESSION_SFINAE
|
||||
// format
|
||||
// basic_string formats
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const zoned_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const zoned_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const zoned_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const zoned_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const utc_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const utc_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const utc_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const utc_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const tai_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const tai_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const tai_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const tai_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const std::locale& loc, const CharT* fmt, const gps_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Duration>
|
||||
std::basic_string<CharT>
|
||||
format(const CharT* fmt, const gps_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT> os;
|
||||
to_stream(os, fmt, tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::locale& loc, const std::basic_string<CharT, Traits>& fmt,
|
||||
const gps_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
os.imbue(loc);
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
template <class CharT, class Traits, class Duration>
|
||||
std::basic_string<CharT, Traits>
|
||||
format(const std::basic_string<CharT, Traits>& fmt, const gps_time<Duration>& tp)
|
||||
{
|
||||
std::basic_ostringstream<CharT, Traits> os;
|
||||
to_stream(os, fmt.c_str(), tp);
|
||||
return os.str();
|
||||
}
|
||||
|
||||
#endif // NO_EXPRESSION_SFINAE
|
||||
|
||||
} // namespace date
|
||||
|
||||
#endif // TZ_H
|
||||
|
Reference in New Issue
Block a user