C++: Boost local time is one hour behind
I am living in the Netherlands, when I run this code:
boost::local_time::local_date_time t = boost::local_time::local_sec_clock::local_time(boost::local_time::time_zone_ptr());
std::cout << "\nDate Time: " << t.to_string() ;
The "Date Time" returned is one hour behind. It is UTC but it should be GMT+1 or UTC+1 for my current system date time!
What should I change to the boost::local_time to get the system date time.
Thanks in advanc开发者_运维问答e.
boost::local_time::time_zone_ptr zone_GMT1(new boost::local_time::posix_time_zone("GMT+1"));
boost::local_time::local_date_time t = boost::local_time::local_sec_clock::local_time(zone_GMT1);
I found out to use the timeZone.
It works fine for me
Thanks!
Maybe you have to enable daylight savings time calculation, by giving an additional parameter set to true (the DST flag), see http://www.boost.org/doc/libs/1_38_0/doc/html/date_time/local_time.html#id3051627
精彩评论