Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2016-05-21 13:34:23 -04:00
parent 1d45d16e6f
commit e5657dc696

@@ -433,36 +433,33 @@ If your OS supports the `std::locale("de_DE")` the above can be simplified to:
using namespace date;
auto zone = current_zone();
auto t10 = sys_days(2002_y/jan/1) + 7h;
auto t11 = zone->to_local(t10);
auto t11 = make_zoned(zone, t10);
std::cout << "UTC <--> Zone base on current setting\n";
std::cout << t11.first << ' ' << t11.second << " is "
<< t10 << " UTC time\n";
auto td = t11.first - t10;
std::cout << t11 << " is " << t10 << " UTC time\n";
auto td = t11.get_local_time().time_since_epoch() - t10.time_since_epoch();
std::cout << "A difference of: " << make_time(td) << '\n';
// eastern timezone is utc-5
zone = locate_zone("America/New_York");
// 5 hours b/f midnight NY time
auto t1 = sys_days(2001_y/dec/31) + 19h + 0s;
auto t1 = local_days{2001_y/dec/31} + 19h + 0s;
std::cout << "\nUTC <--> New York while DST is NOT active (5 hours)\n";
auto t2 = zone->to_sys(t1);
std::cout << t1 << " in New York is " << t2 << " UTC time\n";
auto t2 = make_zoned(zone, t1);
std::cout << t1 << " in New York is " << t2.get_sys_time() << " UTC time\n";
auto t3 = zone->to_local(t2); // back should be the same
std::cout << t2 << " UTC is " << t3 << " New York time\n\n";
std::cout << t2.get_sys_time() << " UTC is " << t2.get_local_time() << " New York time\n\n";
// 4 hours b/f midnight NY time
auto t4 = sys_days(2002_y/may/31) + 20h + 0s;
auto t4 = local_days{2002_y/may/31} + 20h + 0s;
std::cout << "UTC <--> New York while DST is active (4 hours)\n";
auto t5 = zone->to_sys(t4);
std::cout << t4 << " in New York is " << t5 << " UTC time\n";
auto t5 = make_zoned(zone, t4);
std::cout << t4 << " in New York is " << t5.get_sys_time() << " UTC time\n";
auto t6 = zone->to_local(t5); // back should be the same
std::cout << t5 << " UTC is " << t6 << " New York time\n\n";
std::cout << t5.get_sys_time() << " UTC is " << t5.get_local_time() << " New York time\n\n";
// Arizona timezone is utc-7 with no dst
zone = locate_zone("America/Phoenix");
auto t7 = sys_days(2002_y/may/31) + 17h + 0s;
auto t7 = local_days(2002_y/may/31) + 17h + 0s;
std::cout << "UTC <--> Arizona (7 hours)\n";
auto t8 = zone->to_sys(t7);
std::cout << t7 << " in Arizona is " << t8 << " UTC time\n";