mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-03 04:34:26 +02:00
Updated Examples and Recipes (markdown)
@@ -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:
|
||||
|
Reference in New Issue
Block a user