From 095f78fafcd5ba7ad189b0982b224a5ceef8e272 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Sat, 21 May 2016 13:43:27 -0400 Subject: [PATCH] Updated Boost datetime Examples Translated (markdown) --- Boost-datetime-Examples-Translated.md | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/Boost-datetime-Examples-Translated.md b/Boost-datetime-Examples-Translated.md index db6c961..6a98d69 100644 --- a/Boost-datetime-Examples-Translated.md +++ b/Boost-datetime-Examples-Translated.md @@ -516,7 +516,6 @@ an example using the IANA timezone database see the [Local to UTC Conversion](#L ###Flight Time Example - #include "date.h" #include "tz.h" #include @@ -527,27 +526,20 @@ an example using the IANA timezone database see the [Local to UTC Conversion](#L using namespace date; // set up some timezones for creating and adjusting local times - auto nyc_tz = locate_zone("America/New_York"); auto phx_tz = locate_zone("America/Phoenix"); + auto nyc_tz = locate_zone("America/New_York"); // local departure time in phoenix is 11 pm on March 30 2005 // (ny changes to dst on apr 3 at 2 am) - auto phx_departure = sys_days(2005_y/mar/30) + 23h + 0min; - auto utc_departure = phx_tz->to_sys(phx_departure); + auto phx_departure = make_zoned(phx_tz, local_days{2005_y/mar/30} + 23h); - auto flight_length = 4h + 30min; - auto utc_arrival = utc_departure + flight_length; - - auto phx_arrival = phx_tz->to_local(utc_arrival); - auto nyc_arrival = nyc_tz->to_local(utc_arrival); + // flight is 4 hours, 30 minutes + auto phx_arrival = make_zoned(phx_tz, phx_departure.get_sys_time() + 4h + 30min); + auto nyc_arrival = make_zoned(nyc_tz, phx_arrival); std::cout << "departure phx time: " << phx_departure << '\n'; - std::cout << "arrival phx time: " - << floor(phx_arrival) - << ' ' << phx_arrival.second << '\n'; - std::cout << "arrival nyc time: " - << floor(nyc_arrival) - << ' ' << nyc_arrival.second << '\n'; + std::cout << "arrival phx time: " << phx_arrival << '\n'; + std::cout << "arrival nyc time: " << nyc_arrival << '\n'; } // Output: