mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-04 05:04:27 +02:00
Updated Examples and Recipes (markdown)
@@ -137,7 +137,7 @@ main()
|
|||||||
{
|
{
|
||||||
using namespace std::chrono;
|
using namespace std::chrono;
|
||||||
using namespace date;
|
using namespace date;
|
||||||
zoned_time ny{"America/New_York", local_days{jul/8/2016} + 9h};
|
zoned_time ny{"America/New_York", local_days{July/8/2016} + 9h};
|
||||||
zoned_time moscow{"Europe/Moscow", ny};
|
zoned_time moscow{"Europe/Moscow", ny};
|
||||||
std::cout << ny << '\n';
|
std::cout << ny << '\n';
|
||||||
std::cout << moscow << '\n';
|
std::cout << moscow << '\n';
|
||||||
@@ -154,7 +154,7 @@ Then just print it out:
|
|||||||
Obviously you could just as easily specify the meeting in Moscow's time zone and then find the equivalent time in New York:
|
Obviously you could just as easily specify the meeting in Moscow's time zone and then find the equivalent time in New York:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
zoned_time moscow{"Europe/Moscow", local_days{8_d/jul/2016} + 16h};
|
zoned_time moscow{"Europe/Moscow", local_days{8_d/July/2016} + 16h};
|
||||||
zoned_time ny{"America/New_York", moscow};
|
zoned_time ny{"America/New_York", moscow};
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -163,7 +163,7 @@ This would result in the exact same output. For those paying attention, I reord
|
|||||||
Sometimes it is convenient to specify the time independent of either timezone. For example this might be some celestial event such as an eclipse. Often such events are recorded in UTC so that people in all time zones can more easily know the correct time. It is just as easy to use UTC for this example:
|
Sometimes it is convenient to specify the time independent of either timezone. For example this might be some celestial event such as an eclipse. Often such events are recorded in UTC so that people in all time zones can more easily know the correct time. It is just as easy to use UTC for this example:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
auto utc = sys_days{2016_y/jul/8} + 13h;
|
auto utc = sys_days{2016_y/July/8} + 13h;
|
||||||
zoned_time ny{"America/New_York", utc};
|
zoned_time ny{"America/New_York", utc};
|
||||||
zoned_time moscow{"Europe/Moscow", utc};
|
zoned_time moscow{"Europe/Moscow", utc};
|
||||||
```
|
```
|
||||||
@@ -173,7 +173,7 @@ I reordered the date to y/m/d just to show that I could. As long as the first u
|
|||||||
Instead of `local_days`, `sys_days` is used instead. `sys_days` means UTC (technically it means [Unix Time](https://en.wikipedia.org/wiki/Unix_time) which is a very close approximation to UTC). Then you can construct each `zoned_time` with the UTC time (which has type `sys_time<hours>` in this example). You could also construct the second `zoned_time` from the first, just as before:
|
Instead of `local_days`, `sys_days` is used instead. `sys_days` means UTC (technically it means [Unix Time](https://en.wikipedia.org/wiki/Unix_time) which is a very close approximation to UTC). Then you can construct each `zoned_time` with the UTC time (which has type `sys_time<hours>` in this example). You could also construct the second `zoned_time` from the first, just as before:
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
zoned_time ny{"America/New_York", sys_days{jul/8/2016} + 13h};
|
zoned_time ny{"America/New_York", sys_days{July/8/2016} + 13h};
|
||||||
zoned_time moscow{"Europe/Moscow", ny};
|
zoned_time moscow{"Europe/Moscow", ny};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user