Updated Boost datetime Examples Translated (markdown)

Howard Hinnant
2017-07-07 21:31:42 -04:00
parent 4a9dd9c49b
commit ff4852e301

@@ -480,44 +480,44 @@ main()
```
<a name="Flight_Time_Example"></a>
### Flight Time Example
```c++
#include "tz.h"
#include <iostream>
#include "tz.h"
#include <iostream>
int
main()
{
using namespace std::chrono;
using namespace date;
int
main()
{
using namespace std::chrono;
using namespace date;
// set up some timezones for creating and adjusting local times
auto phx_tz = locate_zone("America/Phoenix");
auto nyc_tz = locate_zone("America/New_York");
// set up some timezones for creating and adjusting local times
auto phx_tz = locate_zone("America/Phoenix");
auto nyc_tz = locate_zone("America/New_York");
// local departure time in phoenix is 11 pm on March 30 2005
// (ny changes to dst on apr 3 at 2 am)
auto phx_departure = make_zoned(phx_tz, local_days{2005_y/mar/30} + 23h);
// local departure time in phoenix is 11 pm on March 30 2005
// (ny changes to dst on apr 3 at 2 am)
auto phx_departure = make_zoned(phx_tz, local_days{2005_y/mar/30} + 23h);
// flight is 4 hours, 30 minutes
auto phx_arrival = make_zoned(phx_tz, phx_departure.get_sys_time() + 4h + 30min);
auto nyc_arrival = make_zoned(nyc_tz, phx_arrival);
// flight is 4 hours, 30 minutes
auto phx_arrival = make_zoned(phx_tz, phx_departure.get_sys_time() + 4h + 30min);
auto nyc_arrival = make_zoned(nyc_tz, phx_arrival);
std::cout << "departure phx time: " << phx_departure << '\n';
std::cout << "arrival phx time: " << phx_arrival << '\n';
std::cout << "arrival nyc time: " << nyc_arrival << '\n';
}
// Output:
//
// departure phx time: 2005-03-30 23:00
// arrival phx time: 2005-03-31 03:30 MST
// arrival nyc time: 2005-03-31 05:30 EST
//
// 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
// those that were in effect in 2005. This library varies its DST rules
// with the date.
std::cout << "departure phx time: " << phx_departure << '\n';
std::cout << "arrival phx time: " << phx_arrival << '\n';
std::cout << "arrival nyc time: " << nyc_arrival << '\n';
}
// Output:
//
// departure phx time: 2005-03-30 23:00
// arrival phx time: 2005-03-31 03:30 MST
// arrival nyc time: 2005-03-31 05:30 EST
//
// 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
// those that were in effect in 2005. This library varies its DST rules
// with the date.
```
<a name="Seconds_Since_Epoch"></a>
### Seconds Since Epoch