Updated Examples and Recipes (markdown)

Howard Hinnant
2017-07-07 21:44:07 -04:00
parent 8665f87cbe
commit 76ec8724c0

@@ -101,7 +101,7 @@ main()
auto current_time = std::chrono::system_clock::now(); auto current_time = std::chrono::system_clock::now();
auto la = date::make_zoned("America/Los_Angeles", current_time); auto la = date::make_zoned("America/Los_Angeles", current_time);
auto sy = date::make_zoned("Australia/Sydney", current_time); auto sy = date::make_zoned("Australia/Sydney", current_time);
std::cout << date::make_time(sy.get_local_time() - la.get_local_time()) << '\n'; std::cout << date::format("%T\n", sy.get_local_time() - la.get_local_time());
} }
``` ```
Let's say you want to find out how many hours ahead Sydney is from LA (now). First get the current UTC time. Then create a `zoned_time` for both "America/Los_Angeles" and "Australia/Sydney" using that current UTC time. Then subtract their `local_time`s. `make_time` is a handy formatting tool for printing out that duration: Let's say you want to find out how many hours ahead Sydney is from LA (now). First get the current UTC time. Then create a `zoned_time` for both "America/Los_Angeles" and "Australia/Sydney" using that current UTC time. Then subtract their `local_time`s. `make_time` is a handy formatting tool for printing out that duration: