1
#include "boost/date_time/gregorian/gregorian.hpp"
2
#include "boost/date_time/posix_time/posix_time.hpp"
3
#include "boost/date_time/local_time/local_time.hpp"
8
using namespace boost::gregorian;
9
using namespace boost::posix_time;
10
using namespace boost::local_time;
14
tz_db.load_from_file("../../data/date_time_zonespec.csv");
15
}catch(data_not_accessible dna) {
16
std::cerr << "Error with time zone data file: " << dna.what() << std::endl;
18
}catch(bad_field_count bfc) {
19
std::cerr << "Error with time zone data file: " << bfc.what() << std::endl;
23
time_zone_ptr nyc = tz_db.time_zone_from_region("America/New_York");
24
local_date_time ny_time(date(2004, Aug, 30), hours(10), nyc, true);
26
typedef boost::date_time::time_facet<local_date_time, char> ldt_facet;
27
ldt_facet* timefacet = new ldt_facet("%Y-%b-%d %H:%M:%S""%F %Z");
28
std::locale loc(std::locale::classic(), timefacet);
30
std::cout << ny_time << std::endl;
31
// 2004-Aug-30 10:00:00 EDT
33
std::cout << ny_time << std::endl;
34
// 2004-Aug-30 10:00:00 Eastern Daylight Time
40
/* Copyright 2004-2005: CrystalClear Software, Inc
41
* http://www.crystalclearsoftware.com
43
* Subject to the Boost Software License, Version 1.0.
44
* (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)