boost location-dependent times
1. local_date_time
#include <boost/date_time/local_time/local_time.hpp>
#include <iostream> using namespace boost::local_time;
using namespace boost::posix_time;
using namespace boost::gregorian; int main()
{
time_zone_ptr tz(new posix_time_zone( "CET+1"));
ptime pt{date{, , }, time_duration{, , }};
local_date_time dt{pt, tz};
std::cout << dt.utc_time() << std::endl;
std::cout << dt << std::endl;
std::cout << dt.local_time() << std::endl;
std::cout << dt.zone_name() << std::endl;
return ;
}
The constructor of boost::local_time::local_date_time expects its first parameter to be an object of type boost::posix_time::ptime and its second parameter to be an object of type boost::local_time::time_zone_ptr. boost::local_time::time_zone_ptr is a type of definition for boost::shared_ptr<boost::local_time::time_zone>. The type definition is based on boost::local_time::time_zone, not boost::local_time::posix_time_zone.
Values used to initialize objects of type boost::posix_time::ptime and boost::local_time::local_date_time always relate to the UTC time zone by default.
When an object of type boost::local_time::local_date_time
is written to the standard output stream or a call to the member function local_time()
is made, the deviation in hours is used to calculate the local time.
2. local_time_period
#include <boost/date_time/local_time/local_time.hpp>
#include <iostream> using namespace boost::local_time;
using namespace boost::posix_time;
using namespace boost::gregorian; int main()
{
time_zone_ptr tz(new posix_time_zone("CET+0")); ptime pt1(date(, , 5), time_duration(, , 0));
local_date_time dt1(pt1, tz); ptime pt2(date(, , 5), time_duration(, , 0));
local_date_time dt2(pt2, tz); local_time_period tp(dt1, dt2); std::cout.setf(std::ios::boolalpha);
std::cout << tp.contains(dt1) << std::endl;
std::cout << tp.contains(dt2) << std::endl;
return ;
}
The constructor of boost::local_time::local_time_period
in example above expects two parameters of type boost::local_time::local_date_time
. As with other types provided for periods, the second parameter, which represents the end time, is not part of the period.
boost location-dependent times的更多相关文章
- vs2008编译boost
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库 ...
- Using Boost Libraries in Windows Store and Phone Applications
Using Boost Libraries in Windows Store and Phone Applications RATE THIS Steven Gates 18 Jul 2014 5:3 ...
- Boost 1.62.0 编译参数
# Copyright Vladimir Prus 2002-2006.# Copyright Dave Abrahams 2005-2006.# Copyright Rene Rivera 2005 ...
- 编译Boost 详细步骤
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一. Boost库由C++标准委员会 ...
- 编译Boost 详细步骤 适用 VC6 VS2003 VS2005 VS2008 VS2010
vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库 ...
- Boost的VS开发环境搭建
1. 下载并解压Boost C++ Libs 下载地址: SourceForge:http://sourceforge.net/projects/boost/files/boost/1.48.0/ B ...
- BOOST编译方法
Windowsbjam --toolset=msvc-9.0 --prefix=C:\vc9_boost\vc9 --build-type=complete link=static threading ...
- boost 库编译选项
boost大部分库仅仅须要包括头文件就可以使用,而有部分须要编译的.例如以下: E:\Qt\Qt3rdlib\boost_1_58_0>bjam --show-libraries The fol ...
- windows安装boost
2019年11月4日16:00:36 Boost.Asio 使用文档 https://mmoaay.gitbooks.io/boost-asio-cpp-network-programming-chi ...
- Could not find the following Boost libraries: boost_python3
安装Boost.NumPy时报错: CMake Error at /usr/share/cmake/Modules/FindBoost.cmake:1794 (message): Unable to ...
随机推荐
- Java实践-远程调用Shell脚本并获取输出信息
1.添加依赖 <dependency> <groupId>ch.ethz.ganymed</groupId> <artifactId>ganymed-s ...
- STL容器内数据删除
STL中的容器按存储方式分为两类,一类是按以数组形式存储的容器(如:vector .deque):另一类是以不连续的节点形式存储的容器(如:list.set.map).在使用erase方法来删除元素时 ...
- ''.startswith() and ''.endswith() instead of string slicing to check for prefixes or suffixes.
w http://legacy.python.org/dev/peps/pep-0008/ Yes: if foo.startswith('bar'):No: if foo[:3] == 'bar' ...
- vue同意本站协议的制作
<!doctype html> <html> <head> <meta charset="UTF-8"> <title> ...
- Git014--Rebase
Git--Rebase 本文来自于:https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b00 ...
- 回调-> 观察者模式->反应堆模式
关于回调: 回调是观察者模式以及反应堆模式的基础 一句话,回调就是一种双向调用模式,什么意思呢,就是说,被调用方在被调用时也会调用对方,这就叫回调.“If you call me, i will ca ...
- Pair Testing
All-Pairs Testing is a test design method to deal with the combinatorics problem of defining test ca ...
- 【转载】ROS系统整体架构
目录 1.从文件系统级理解 2.从计算图级理解 3.从开源社区级理解 由于ROS系统的组织架构比较复杂,简单从一个方面来说明很难说清楚.按照ROS官方的说法,我们可以从3个方面来理解ROS系统整体架构 ...
- spring-第十九篇AOP面向切面编程之增强处理的优先级
1.从我们第十七篇举例了不同类型的增强处理. spring AOP采用和AspectJ一样的优先顺序来织入增强处理:在“进入”连接点时,具有最高优先级的增强处理将先被织入(在给定的两个Before增强 ...
- 使用Angular2+的内置管道格式化数据
在简书看到一篇关于Angualr运用内置管道格式化数据的总结,感觉挺实用的,转载一下以供参考: [转载]https://www.jianshu.com/p/a8bd5a1d2c53 PS:管道是在HT ...