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的更多相关文章

  1. vs2008编译boost

    vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库 ...

  2. 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 ...

  3. Boost 1.62.0 编译参数

    # Copyright Vladimir Prus 2002-2006.# Copyright Dave Abrahams 2005-2006.# Copyright Rene Rivera 2005 ...

  4. 编译Boost 详细步骤

    vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一. Boost库由C++标准委员会 ...

  5. 编译Boost 详细步骤 适用 VC6 VS2003 VS2005 VS2008 VS2010

    vs2008编译boost [一.Boost库的介绍] Boost库是一个经过千锤百炼.可移植.提供源代码的C++库,作为标准库的后备,是C++标准化进程的发动机之一.Boost库由C++标准委员会库 ...

  6. Boost的VS开发环境搭建

    1. 下载并解压Boost C++ Libs 下载地址: SourceForge:http://sourceforge.net/projects/boost/files/boost/1.48.0/ B ...

  7. BOOST编译方法

    Windowsbjam --toolset=msvc-9.0 --prefix=C:\vc9_boost\vc9 --build-type=complete link=static threading ...

  8. boost 库编译选项

    boost大部分库仅仅须要包括头文件就可以使用,而有部分须要编译的.例如以下: E:\Qt\Qt3rdlib\boost_1_58_0>bjam --show-libraries The fol ...

  9. windows安装boost

    2019年11月4日16:00:36 Boost.Asio 使用文档 https://mmoaay.gitbooks.io/boost-asio-cpp-network-programming-chi ...

  10. Could not find the following Boost libraries: boost_python3

    安装Boost.NumPy时报错: CMake Error at /usr/share/cmake/Modules/FindBoost.cmake:1794 (message): Unable to ...

随机推荐

  1. sqlalchemy.exc.NoForeignKeysError:Can't find any foreign key relationships between

    这句话的意思是,两张表之间的外键找不到,首先看看外键设置正确了没,如果外键没问题,看看是不是_tablename_设置了没,就是再model中,定义类的时候,表格名称要_tablename_设置一下, ...

  2. 一文读懂PID控制算法(抛弃公式,从原理上真正理解PID控制)

      PID控制应该算是应用非常广泛的控制算法了.小到控制一个元件的温度,大到控制无人机的飞行姿态和飞行速度等等,都可以使用PID控制.这里我们从原理上来理解PID控制. PID(proportion ...

  3. Windows 环境下vue+webpack前端开发环境搭建

    一.开发环境搭建 1.前端框架一般依赖node.js,我们首先要安装node.js. 2.由于许多npm 的源都在国外的地址,安装起来特别慢,所以我们这里利用淘宝的镜像服务器. 安装命令为:npm i ...

  4. Hive 窗口函数之 lead() over(partition by ) 和 lag() over(partition by )

    lead函数用于提取当前行前某行的数据 lag函数用于提取当前行后某行的数据 语法如下: lead(expression,offset,default) over(partition by ... o ...

  5. Vagrant 手册之 box - 概述

    原文地址 box 是 Vagrant 环境中使用的包格式.box 可以在 Vagrant 支持的所有平台上被任何人使用,从而提供相同的工作环境. vagrant box 工具提供了管理 box 的所有 ...

  6. HTML-字符实体,平方米(㎡)m²

    转载自:https://blog.csdn.net/hangGe0111/article/details/80983250

  7. canvas绘制小人开口和闭口

    css: <style> body{ text-align: center; } canvas{ background: #ddd; } </style>canvas标签:&l ...

  8. springboot jpa 级联操作及测试问题 (@Transactional与@Test)

    前言:测试springboot版本     :springBootVersion = '2.0.5.RELEASE' 一 :搬运@Transactional B. 如果加了事务,必须做好开发环境测试( ...

  9. mac安装pip并升级pip版本

      最近想安装inchat,直接使用命令pip install install,结果提示 使用提示中的命令升级,结果提示找不到pip.很郁闷,明明有pip,结果一升级还给升没了.最后用的是这个方法完美 ...

  10. Netty之SubPage级别的内存分配

    SubPage 级别的内存分配: 通过之前的学习我们知道, 如果我们分配一个缓冲区大小远小于page, 则直接在一个page 上进行分配则会造成内存浪费, 所以需要将page 继续进行切分成多个子块进 ...