C++ 将时间转换为东部标准时间UTC-5:00

C++ 将时间转换为东部标准时间UTC-5:00,c++,boost,boost-date-time,C++,Boost,Boost Date Time,我使用以下代码获取当前日期时间(山区时间) 现在我使用以下方法进行转换 ptime FeedConnector::MountaintToEasternConversion(ptime coloTime) { return boost::date_time::local_adjustor <ptime, -5, us_dst>::utc_to_local(coloTime); } 时间错了吗?有人建议我哪里出了问题吗?据我所知,错误时间意味着它与预期时间相差一小时,

我使用以下代码获取当前日期时间(山区时间)

现在我使用以下方法进行转换

ptime FeedConnector::MountaintToEasternConversion(ptime coloTime) 
{

      return boost::date_time::local_adjustor <ptime, -5, us_dst>::utc_to_local(coloTime);
} 

时间错了吗?有人建议我哪里出了问题吗?

据我所知,
错误时间
意味着它与预期时间相差一小时,即-4小时,而不是预期的-5小时。如果是,则问题在于
us\u std
类型被指定为
local\u调节器
声明的最后一个参数。如果要指定
no_dst
而不是
,请使用_dst
。代码的工作原理与所阐述的相同,差异为-5小时。下面的代码演示了它()

#包括
#包括
#包括
内部主(空){
const boost::posix_time::ptime now=boost::posix_time::second_clock::local_time();
const boost::posix_time::ptime adjustst=boost::date_time::local_adjustor::utc_to_local(现在);
const boost::posix_time::ptime adjNODST=boost::date_time::local_adjustor::utc_to_local(现在);

我也想知道答案吗。
ptime FeedConnector::MountaintToEasternConversion(ptime coloTime) 
{

      return boost::date_time::local_adjustor <ptime, -5, us_dst>::utc_to_local(coloTime);
} 
2013-Apr-08 16:44:22
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/date_time/local_time_adjustor.hpp>
#include <iostream>

int main(void) {
   const boost::posix_time::ptime now = boost::posix_time::second_clock::local_time();
   const boost::posix_time::ptime adjUSDST = boost::date_time::local_adjustor<boost::posix_time::ptime, -5, boost::posix_time::us_dst>::utc_to_local(now);
   const boost::posix_time::ptime adjNODST = boost::date_time::local_adjustor<boost::posix_time::ptime, -5, boost::posix_time::no_dst>::utc_to_local(now);
   std::cout << "now: " << now << std::endl;
   std::cout << "adjUSDST: " << adjUSDST << std::endl;
   std::cout << "adjNODST: " << adjNODST << std::endl;
   return 0;
}