From 76ec8724c0466bf0cae8dfcb142a70d4320978bf Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Fri, 7 Jul 2017 21:44:07 -0400 Subject: [PATCH] Updated Examples and Recipes (markdown) --- Examples-and-Recipes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples-and-Recipes.md b/Examples-and-Recipes.md index bae905b..aa8cd01 100644 --- a/Examples-and-Recipes.md +++ b/Examples-and-Recipes.md @@ -101,7 +101,7 @@ main() auto current_time = std::chrono::system_clock::now(); auto la = date::make_zoned("America/Los_Angeles", 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: