473,387 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

time with libboost_date_time

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::posix_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;

}
Feb 7 '07 #1
1 2763
Gary Wessle <ph****@yahoo.comwrites:
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::posix_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;

}
OR

// exctact the date and duration since 00:00:00 from now
date in_date(2004,10,04); // example
time_duration td(12,14,32); // example
// create the local_date_time in sydney
local_date_time syd_time(in_date,
td,
syd_tz,
local_date_time::NOT_DATE_TIME_ON_ERROR);
/* but how can I get date and time_duration form now */
/* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^*/

// convert it to New York
local_date_time in_ny = in_sydney.local_time_in(nyc_tz);

// print time now in New York.
cout << "\nNow in New York " << in_ny << endl;
Feb 7 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Bart Nessux | last post by:
am I doing this wrong: print (time.time() / 60) / 60 #time.time has been running for many hours if time.time() was (21600/60) then that would equal 360/60 which would be 6, but I'm not getting...
5
by: David Stockwell | last post by:
I'm sure this has been asked before, but I wasn't able to find it. First off I know u can't change a tuple but if I wanted to increment a time tuple by one day what is the standard method to do...
6
by: David Graham | last post by:
Hi I have asked this question in alt.php as the time() function as used in setcookie belongs to php - or does it belong equally in the javascript camp - bit confused about that. Anyway, can anyone...
4
by: Andrew Poulos | last post by:
How do I convert a length of time, measured in seconds, into a "point in time" type time interval or what's represented as: time (second,10,2) The format is: PS]] where: y: The number of...
8
by: peterbe | last post by:
What's the difference between time.clock() and time.time() (and please don't say clock() is the CPU clock and time() is the actual time because that doesn't help me at all :) I'm trying to...
3
by: Szabolcs Nagy | last post by:
I have to measure the time of a while loop, but with time.clock i always get 0.0s, although python manual sais: "this is the function to use for benchmarking Python or timing algorithms" So i...
6
by: cournape | last post by:
Hi there, I have some scientific application written in python. There is a good deal of list processing, but also some "simple" computation such as basic linear algebra involved. I would like to...
5
by: Erich Schreiber | last post by:
In the Python Library Reference the explanation of the time.sleep() function reads amongst others: > The actual suspension time may be less than that requested because > any caught signal will...
6
by: Rebecca Smith | last post by:
Today’s question involves two time text boxes each set to a different time zone. Initially txtCurrentTime will be set to Pacific Time or system time. This will change with system time as we travel...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.