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 ...
随机推荐
- 002-序列化装换JSON&XML概述
一.概述 https://github.com/bjlhx15/java-serializer java-serializer 序列化项目 serialize-json-lib:json-lib框架 ...
- delphi中的idhttpserver如何才能收到idhttp发送来的exe\rar文件呢
http://zhidao.baidu.com/link?url=-q2oXqYCKBZ9OgFDEHAcQwQEY_NroHcqGvVfKW67X5sF9LdjAAB_HPXQo04VxStFVS7 ...
- HTML--JS 随机背景色
<html> <head> <title>背景随机变色</title> <script type="text/javascript&qu ...
- 网络流强化-POJ2516
k种货物分开求解最小费用最大流,主要减少了寻找最短路的时间. #include<queue> #include<cstdio> #include<cstring> ...
- Using Tensorflow SavedModel Format to Save and Do Predictions
We are now trying to deploy our Deep Learning model onto Google Cloud. It is required to use Google ...
- vuejs基础-计算器案例
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...
- Chrome打开标签页预览
类似于Microsoft Edge浏览器上的标签页缩略图预览非常方便,其实现在谷歌浏览器正在测试相关的功能,如果想提前体验,就在地址栏输入"chrome://flags"并按下回车 ...
- 《JAVA设计模式》之责任链模式(Chain of Responsibility)
在阎宏博士的<JAVA与模式>一书中开头是这样描述责任链(Chain of Responsibility)模式的: 责任链模式是一种对象的行为模式.在责任链模式里,很多对象由每一个对象对其 ...
- Spring Cloud Stream 进行服务之间的通讯
Spring Cloud Stream Srping cloud Bus的底层实现就是Spring Cloud Stream,Spring Cloud Stream的目的是用于构建基于消息驱动(或事件 ...
- 构建自己的AngularJS,第一部分:作用域和digest 转摘:http://www.ituring.com.cn/article/39865
构建自己的AngularJS,第一部分:Scope和Digest 原文链接:http://teropa.info/blog/2013/11/03/make-your-own-angular-part- ...