mirror of
https://github.com/HowardHinnant/date.git
synced 2025-08-06 14:14:27 +02:00
Updated Boost datetime Examples Translated (markdown)
@@ -482,7 +482,7 @@ main()
|
|||||||
<a name="Flight_Time_Example"></a>
|
<a name="Flight_Time_Example"></a>
|
||||||
### Flight Time Example
|
### Flight Time Example
|
||||||
```c++
|
```c++
|
||||||
#include "tz.h"
|
#include "date/tz.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -497,11 +497,11 @@ main()
|
|||||||
|
|
||||||
// local departure time in phoenix is 11 pm on March 30 2005
|
// local departure time in phoenix is 11 pm on March 30 2005
|
||||||
// (ny changes to dst on apr 3 at 2 am)
|
// (ny changes to dst on apr 3 at 2 am)
|
||||||
auto phx_departure = make_zoned(phx_tz, local_days{2005_y/mar/30} + 23h);
|
zoned_seconds phx_departure{phx_tz, local_days{2005_y/March/30} + 23h};
|
||||||
|
|
||||||
// flight is 4 hours, 30 minutes
|
// flight is 4 hours, 30 minutes
|
||||||
auto phx_arrival = make_zoned(phx_tz, phx_departure.get_sys_time() + 4h + 30min);
|
zoned_seconds phx_arrival{phx_tz, phx_departure.get_sys_time() + 4h + 30min};
|
||||||
auto nyc_arrival = make_zoned(nyc_tz, phx_arrival);
|
zoned_seconds nyc_arrival{nyc_tz, phx_arrival};
|
||||||
|
|
||||||
std::cout << "departure phx time: " << phx_departure << '\n';
|
std::cout << "departure phx time: " << phx_departure << '\n';
|
||||||
std::cout << "arrival phx time: " << phx_arrival << '\n';
|
std::cout << "arrival phx time: " << phx_arrival << '\n';
|
||||||
@@ -510,9 +510,9 @@ main()
|
|||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
// departure phx time: 2005-03-30 23:00
|
// departure phx time: 2005-03-30 23:00:00 MST
|
||||||
// arrival phx time: 2005-03-31 03:30 MST
|
// arrival phx time: 2005-03-31 03:30:00 MST
|
||||||
// arrival nyc time: 2005-03-31 05:30 EST
|
// arrival nyc time: 2005-03-31 05:30:00 EST
|
||||||
//
|
//
|
||||||
// Note that boost states a nyc_arrival time of 2005-Mar-31 06:30:00 EDT
|
// Note that boost states a nyc_arrival time of 2005-Mar-31 06:30:00 EDT
|
||||||
// because boost uses the current US daylightsavings rules as opposed to
|
// because boost uses the current US daylightsavings rules as opposed to
|
||||||
|
Reference in New Issue
Block a user