diff --git a/tz.h b/tz.h index 1e1d92f..1c10b7b 100644 --- a/tz.h +++ b/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"); else { - auto info = zone->get_info(tp); + auto info = zone->get_info(tp).first; auto offset = duration_cast(info.offset); ostringstream os; 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"); else { - auto info = zone->get_info(tp); + auto info = zone->get_info(tp).first; format.replace(i, 2, info.abbrev); i += info.abbrev.size() - 1; } @@ -1380,10 +1380,13 @@ parse(std::istream& is, const std::string& format, sys_time& tp) template inline void -parse(std::istream& is, const std::string& format, sys_time& tp, +parse(std::istream& is, const std::string& format, local_time& tp, std::string& abbrev) { - detail::parse(is, format, tp, &abbrev); + sys_time st; + detail::parse(is, format, st, &abbrev); + if (!is.fail()) + tp = local_time{st.time_since_epoch()}; } } // namespace date