⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testc_local_adjustor.cpp

📁 C++的一个好库。。。现在很流行
💻 CPP
字号:
/* Copyright (c) 2002,2003 CrystalClear Software, Inc.
 * Use, modification and distribution is subject to the 
 * Boost Software License, Version 1.0. (See accompanying
 * file LICENSE-1.0 or http://www.boost.org/LICENSE-1.0)
 * Author: Jeff Garland 
 */

#include "boost/date_time/posix_time/posix_time.hpp"
#include "boost/date_time/c_local_time_adjustor.hpp"
#include "boost/date_time/testfrmwk.hpp"

int
main() 
{
  using namespace boost::posix_time;
  using namespace boost::gregorian;

  //These are a compile check / test.  They have to be hand inspected
  //b/c they depend on the TZ settings of the machine and hence it is
  //unclear what the results will be
  typedef boost::date_time::c_local_adjustor<ptime> local_adj;

  ptime t1(date(2002,Jan,1), hours(7)+millisec(5)); 
  std::cout << "UTC <--> TZ Setting of Machine -- No DST" << std::endl;
  ptime t2 = local_adj::utc_to_local(t1);
  std::cout << to_simple_string(t2) << " LOCAL is " 
            << to_simple_string(t1) << " UTC time "
            << std::endl;
  time_duration td1 = t2 - t1;
  std::cout << "A difference of: " << to_simple_string(td1)
            << std::endl;


  ptime t3(date(2002,May,1), hours(5)+millisec(5)); 
  std::cout << "UTC <--> TZ Setting of Machine -- In DST" << std::endl;
  ptime t4 = local_adj::utc_to_local(t3);
  std::cout << to_simple_string(t4) << " LOCAL is " 
            << to_simple_string(t3) << " UTC time "
            << std::endl;
  time_duration td2 = t4 - t3;
  std::cout << "A difference of: " << to_simple_string(td2)
            << std::endl;

  return printTestStats();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -