Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2016-05-21 13:49:33 -04:00
parent 095f78fafc
commit f2bc57a9ff

@@ -566,16 +566,16 @@ an example using the IANA timezone database see the [Local to UTC Conversion](#L
using namespace std::chrono;
using namespace date;
auto nyc_tz = locate_zone("America/New_York");
auto nyc_time = sys_days(2004_y/oct/4) + 12h + 14min + 32s;
auto nyc_time = make_zoned("America/New_York",
local_days(2004_y/oct/4) + 12h + 14min + 32s);
std::cout << nyc_time << '\n';
auto time_t_epoch = sys_days(1970_y/1/1);
std::cout << time_t_epoch << '\n';
// first convert nyc_time to utc via the utc_time()
// call and subtract the ptime.
auto sys_time = nyc_tz->to_sys(nyc_time);
auto diff = sys_time - time_t_epoch;
// first convert nyc_time to utc via the get_sys_time()
// call and subtract the time_t_epoch.
auto sys_time = nyc_time.get_sys_time();
auto diff = nyc_time.get_sys_time() - time_t_epoch;
// Expected 1096906472
std::cout << "Seconds diff: " << diff.count() << '\n';
@@ -587,4 +587,4 @@ an example using the IANA timezone database see the [Local to UTC Conversion](#L
// Expected 1096906494, an extra 22s
std::cout << "Seconds diff: " << diff.count() << '\n';
}
}