G
Gary Wessle
Hi
could someone please tell us how to do this:
my PC time is set to Australia/Sydney.
I need New York time epoch using libboost_date_time
thank you
#include <iostream>
#include "boost/date_time/local_time/local_time.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace std;
int main(){
using namespace boost::gregorian;
using namespace boost::local_time;
using namespace boost:
osix_time;
// get the PC time and make sure it stays correct
ptime now = second_clock::local_time(); // current PC time
cout << "Your computer time is: " << now << endl;
// load time zone conversion date form file
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");
time_zone_ptr syd_tz = tz_db.time_zone_from_region("Australia/Sydney");
/* ................ so fare so good ................ */
// Convert it to NY time epoch (not sure how)
local_date_time in_sydney(now, syd_tz, local_date_time::NOT_DATE_TIME_ON_ERROR);
local_date_time in_ny = in_sydney.local_time_in(nyc_tz);
cout << "\nNow in New York " << in_ny << endl;
}
could someone please tell us how to do this:
my PC time is set to Australia/Sydney.
I need New York time epoch using libboost_date_time
thank you
#include <iostream>
#include "boost/date_time/local_time/local_time.hpp"
#include "boost/date_time/posix_time/posix_time.hpp"
using namespace std;
int main(){
using namespace boost::gregorian;
using namespace boost::local_time;
using namespace boost:
// get the PC time and make sure it stays correct
ptime now = second_clock::local_time(); // current PC time
cout << "Your computer time is: " << now << endl;
// load time zone conversion date form file
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");
time_zone_ptr syd_tz = tz_db.time_zone_from_region("Australia/Sydney");
/* ................ so fare so good ................ */
// Convert it to NY time epoch (not sure how)
local_date_time in_sydney(now, syd_tz, local_date_time::NOT_DATE_TIME_ON_ERROR);
local_date_time in_ny = in_sydney.local_time_in(nyc_tz);
cout << "\nNow in New York " << in_ny << endl;
}