Updated Examples and Recipes (markdown)

Howard Hinnant
2021-04-22 14:13:37 -04:00
parent 7de0a2ebe2
commit 0541e58c2b

@@ -105,12 +105,33 @@ main()
This outputs the current time in Shanghai, for example:
```c++
```
2016-07-06 11:01:05.818378 CST
```
All IANA timezone names (or links -- aliases to timezones) are supported.
Like with the current local time, if you just want a local `time_point` (without the timezone abbreviation), you can work directly with the `time_zone` if desired:
```c++
#include "date/tz.h"
#include <iostream>
int
main()
{
using date::operator<<;
std::cout << date::locate_zone("Asia/Shanghai")->
to_local(std::chrono::system_clock::now()) << '\n';
}
```
```
2016-07-06 11:01:05.818378
```
If `locate_zone()` can't find the `time_zone`, it will throw a `std::runtime_error` with a helpful `what()` message.
<a name="deltatz"></a>
### Get the current difference between any two arbitrary time zones
(by [Howard Hinnant](https://github.com/HowardHinnant))