forked from HowardHinnant/date
minor fixes in format and parse
This commit is contained in:
11
tz.h
11
tz.h
@@ -1151,7 +1151,7 @@ format(const std::locale& loc, std::string format,
|
|||||||
throw std::runtime_error("Can not format local_time with %z");
|
throw std::runtime_error("Can not format local_time with %z");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto info = zone->get_info(tp);
|
auto info = zone->get_info(tp).first;
|
||||||
auto offset = duration_cast<minutes>(info.offset);
|
auto offset = duration_cast<minutes>(info.offset);
|
||||||
ostringstream os;
|
ostringstream os;
|
||||||
if (offset >= minutes{0})
|
if (offset >= minutes{0})
|
||||||
@@ -1168,7 +1168,7 @@ format(const std::locale& loc, std::string format,
|
|||||||
throw std::runtime_error("Can not format local_time with %z");
|
throw std::runtime_error("Can not format local_time with %z");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto info = zone->get_info(tp);
|
auto info = zone->get_info(tp).first;
|
||||||
format.replace(i, 2, info.abbrev);
|
format.replace(i, 2, info.abbrev);
|
||||||
i += info.abbrev.size() - 1;
|
i += info.abbrev.size() - 1;
|
||||||
}
|
}
|
||||||
@@ -1380,10 +1380,13 @@ parse(std::istream& is, const std::string& format, sys_time<Duration>& tp)
|
|||||||
template <class Duration>
|
template <class Duration>
|
||||||
inline
|
inline
|
||||||
void
|
void
|
||||||
parse(std::istream& is, const std::string& format, sys_time<Duration>& tp,
|
parse(std::istream& is, const std::string& format, local_time<Duration>& tp,
|
||||||
std::string& abbrev)
|
std::string& abbrev)
|
||||||
{
|
{
|
||||||
detail::parse(is, format, tp, &abbrev);
|
sys_time<Duration> st;
|
||||||
|
detail::parse(is, format, st, &abbrev);
|
||||||
|
if (!is.fail())
|
||||||
|
tp = local_time<Duration>{st.time_since_epoch()};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace date
|
} // namespace date
|
||||||
|
Reference in New Issue
Block a user