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. laravel5.6操作数据curd写法(查询构建器)

    laravel5.6 数据库操作-查询构建器 <?php //laravel5.6 语法 demo示例 namespace App\Http\Controllers;//命名该控制App空间下名 ...

  2. mysql_备份_mysqldump

    命令行执行mysqldump mysqldump -uuser -pPassword dbnametable [option] > xx.sql;mysqldump• Mysqldump常用参数 ...

  3. postgresql中实现按周统计详解

    SELECT EXTRACT(DOW FROM CURRENT_DATE);   执行结果如下. 这个SQL语句的意思就是计算当前日期是一周中的第几天. EXTRACT(DOW FROM CURREN ...

  4. 第 13 章 python并发编程之io模型

    一.IO模型介绍 同步(synchronous) IO和异步(asynchronous) IO,阻塞(blocking) IO和非阻塞(non-blocking)IO分别是什么,到底有什么区别?这个问 ...

  5. HTML--JS 获取选择框信息

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. Maven仓库存在jar包但依旧提示无法下载

    介绍最近服务器的迁移,把原来服务器的地址都更改了,所以私服的地址也改动了,原来项目下载到本地仓库的包,但是重新构建过程中竟然发现依然要提示下载,本地仓库里面明明有包,为什么还要下载? 解决去maven ...

  7. Python入门习题10.河内塔(汉诺塔)问题

    例10 共n个圆盘,a,b,c三根柱子 #汉诺塔问题.py def Hanoi(n): #定义n阶汉诺塔问题移动次数函数 if n == 1: return 1 else: return 2*Hano ...

  8. mysql 分区与性能

    数据库应用分为两类: OLTP(在线事务处理):如bolg.电子商务.网络游戏等 OLAP(在线分析处理):如数据仓库.数据集市 对于OLAP,分区可以很好的提高查询性能,应用大多数据需要频繁地扫描一 ...

  9. dfs(最长路径)

    http://poj.org/problem?id=1154 LETTERS Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: ...

  10. Warning: session_start(): open(/var/lib/php/session/)

    Warning: session_start(): open(/var/lib/php/session/) 今天放置一个新的站点www.96net.com.cn在里面,登陆后台出现这种错,之后再lin ...