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 ...
随机推荐
- 后端技术杂谈11:十分钟理解Kubernetes核心概念
本系列文章将整理到我在GitHub上的<Java面试指南>仓库,更多精彩内容请到我的仓库里查看 本文转自 https://github.com/h2pl/Java-Tutorial 喜欢的 ...
- Python分析《武林外传》
我一向比较喜欢看武侠电影.小说,但是06年武林外传开播的时候并没有追剧,简单扫几眼之后发现他们都不会那种飞来飞去的打,一点也不刺激.09年在南京培训的时候,日子简单无聊透顶,大好的周末不能出门,只能窝 ...
- C#-概念-基础类库:基础类库
ylbtech-C#-概念-基础类库:基础类库 基础类库 (BCL) 是微软所提出的一组标准库可提供.NET Framework所有语言使用. 随着 Windows 以及 .NET Framework ...
- php面向对象重的抽象类,接口类与静态
static 静态 <?php class ren { public $name; public static $sex; static function shao() { echo " ...
- CentOS7.4伪分布式搭建 hadoop+zookeeper+hbase+opentsdb
前言 由于hadoop和hbase都得想zookeeper注册,所以启动顺序为 zookeeper——>hadoop——>hbase,关闭顺序反之 一.前期准备 1.配置ip 进入文件编辑 ...
- SpringBoot 接口并行高效聚合
转自:juejin.im/post/5d064b90e51d45777540fda7 背景 接口开发是后端开发中最常见的场景, 可能是RESTFul接口, 也可能是RPC接口. 接口开发往往是从各处捞 ...
- mysql双主+keepalived架构
架构展示 操作系统 centos6.5 数据库 mysql5.7 master1 10.0.254.148 master2 10.0.254.147 VIP 10.0.254.88 (keepaliv ...
- 观list.clear()方法 有感
一 . list.clear()底层源码实现 在使用list 结合的时候习惯了 list=null :在创建这样的方式,但是发现使用list的clear 方法很不错,尤其是有大量循环的时候 1.lis ...
- HDU 5441 Travel (离线dsu)
<题目链接> 题目大意:$n$个点,$m$条边,每条边具有对应的权值,然后进行$k$次询问,每次询问给定一个值,所有权值小于等于这个的边所对应的点能够相连,问每次询问,这些能够相互到达的点 ...
- CodeForces 711D Directed Roads (DFS找环+组合数)
<题目链接> 题目大意: 给定一个$n$条边,$n$个点的图,每个点只有一条出边(初始状态),现在能够任意对图上的边进行翻转,问你能够使得该有向图不出先环的方案数有多少种. 解题分析: 很 ...