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