mirror of
https://github.com/HowardHinnant/date.git
synced 2025-01-14 17:58:03 +08:00
Optimize to_stream for zoned_time
* Decrease the number of lookups in the database from 2 to 1.
This commit is contained in:
parent
9381e894a5
commit
25696b7fb3
@ -1774,8 +1774,13 @@ std::basic_ostream<CharT, Traits>&
|
|||||||
to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
to_stream(std::basic_ostream<CharT, Traits>& os, const CharT* fmt,
|
||||||
const zoned_time<Duration, TimeZonePtr>& tp)
|
const zoned_time<Duration, TimeZonePtr>& tp)
|
||||||
{
|
{
|
||||||
auto const info = tp.get_info();
|
using duration = typename zoned_time<Duration, TimeZonePtr>::duration;
|
||||||
return to_stream(os, fmt, tp.get_local_time(), &info.abbrev, &info.offset);
|
using LT = local_time<duration>;
|
||||||
|
auto const tz = tp.get_time_zone();
|
||||||
|
auto const st = tp.get_sys_time();
|
||||||
|
auto const info = tz->get_info(st);
|
||||||
|
return to_stream(os, fmt, LT{(st+info.offset).time_since_epoch()},
|
||||||
|
&info.abbrev, &info.offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class CharT, class Traits, class Duration, class TimeZonePtr>
|
template <class CharT, class Traits, class Duration, class TimeZonePtr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user