mirror of
https://github.com/boostorg/date_time.git
synced 2026-01-27 18:52:17 +00:00
https://svn.boost.org/svn/boost/trunk ........ r43417 | danieljames | 2008-02-26 22:04:55 +0000 (Tue, 26 Feb 2008) | 2 lines Fix a link to Boost.Bimap. ........ r43418 | danieljames | 2008-02-26 22:07:25 +0000 (Tue, 26 Feb 2008) | 2 lines Change another link that's no longer in the repository to link to the website. ........ r43422 | danieljames | 2008-02-27 18:51:14 +0000 (Wed, 27 Feb 2008) | 1 line Fix broken copyright urls. Fixes #1573. ........ r43423 | danieljames | 2008-02-27 19:22:01 +0000 (Wed, 27 Feb 2008) | 1 line Fix incorrect links to copyright of the form 'http:#www.boost.org ........ [SVN r43425]
51 lines
1.7 KiB
C++
51 lines
1.7 KiB
C++
|
|
#include "boost/date_time/local_time/local_time.hpp"
|
|
#include <iostream>
|
|
|
|
/* This example shows a program that calculates the arrival time of a plane
|
|
* that flys from Phoenix to New York. During the flight New York shifts
|
|
* into daylight savings time (Phoenix doesn't because Arizona doesn't use
|
|
* dst).
|
|
*
|
|
*
|
|
*/
|
|
|
|
int main()
|
|
{
|
|
using namespace boost::gregorian;
|
|
using namespace boost::local_time;
|
|
using namespace boost::posix_time;
|
|
|
|
|
|
//setup some timezones for creating and adjusting local times
|
|
//This user editable file can be found in libs/date_time/data.
|
|
tz_database tz_db;
|
|
tz_db.load_from_file("date_time_zonespec.csv");
|
|
time_zone_ptr nyc_tz = tz_db.time_zone_from_region("America/New_York");
|
|
//Use a
|
|
time_zone_ptr phx_tz(new posix_time_zone("MST-07:00:00"));
|
|
|
|
//local departure time in phoenix is 11 pm on april 2 2005
|
|
// (ny changes to dst on apr 3 at 2 am)
|
|
local_date_time phx_departure(date(2005, Apr, 2), hours(23),
|
|
phx_tz,
|
|
local_date_time::NOT_DATE_TIME_ON_ERROR);
|
|
|
|
time_duration flight_length = hours(4) + minutes(30);
|
|
local_date_time phx_arrival = phx_departure + flight_length;
|
|
local_date_time nyc_arrival = phx_arrival.local_time_in(nyc_tz);
|
|
|
|
std::cout << "departure phx time: " << phx_departure << std::endl;
|
|
std::cout << "arrival phx time: " << phx_arrival << std::endl;
|
|
std::cout << "arrival nyc time: " << nyc_arrival << std::endl;
|
|
|
|
}
|
|
|
|
|
|
/* Copyright 2005: CrystalClear Software, Inc
|
|
* http://www.crystalclearsoftware.com
|
|
*
|
|
* Subject to the Boost Software License, Version 1.0.
|
|
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
|
|
*/
|