Boost.Chrono主场迎战的Boost.Date_Time [英] Boost.Chrono vs. Boost.Date_Time

查看:234
本文介绍了Boost.Chrono主场迎战的Boost.Date_Time的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用升压1.47版本,引入了计时库。被Boost.Chrono目的是为的Boost.Date_Time更换?

With Boost version 1.47, the Chrono library was introduced. Is Boost.Chrono meant as a replacement for Boost.Date_Time?

如果没有,是什么他们,当我应该使用哪一个?

If not, what are the differences between them and when should I use which?

当我应该考虑现有的项目替换的Boost.Date_Time由Boost.Chrono?

When should I consider replacing Boost.Date_Time by Boost.Chrono in an existing project?

推荐答案

从Boost.Chrono的文档:

From Boost.Chrono's documentation:

Boost.Chrono旨在实现的C ++ 0x新设施时,如N2661建议 - 一个基础上睡觉。该文件提供了背景和动机关键设计决策,是本文档中一个很好的协议信息的来源。

Boost.Chrono aims to implement the new time facilities in C++0x, as proposed in N2661 - A Foundation to Sleep On. That document provides background and motivation for key design decisions and is the source of a good deal of information in this documentation.

更具体地说,Boost.DateTime左右,好了,日期和时间。它有大量的功能,根据语言环境和其他各种东西格式化日期显示。但也有获取日期和时间,以及对他们的操作功能。

More specifically, Boost.DateTime is about, well, dates and times. It has lots of functions for formatting dates for display according to locales and various other things. But there are also functions for getting dates and times, as well as operating on them.

Boost.Chrono似乎集中于处理的时间间隔。它没有测量不是小时更高,且无日期的概念都没有。事实上,在时间的时刻仅支持作为相对于一个特定时刻(时间,因为进程启动,时间,因为一个固定的划时代像1970年1月1日,等等)。

Boost.Chrono seems focused on dealing with time intervals. It has no measurement higher than "hours", and it has no concept of date at all. Indeed, moments in time are only supported as offsets to a particular moment in time (time since process started, time since a fixed "epoch" like Jan 1, 1970, etc).

这两个看似互补,而不是相互竞争的,虽​​然有一些重叠。有很多的日期时间这是否计时不,有一些事情,不计时的日期时间不。可悲的是,似乎没有被任何两者之间的互操作,所以便要计时的持续时间手工转换成DateType的等价物。

The two seem complementary, rather than competing, though there is some overlap. There is a lot that DateTime does that Chrono doesn't, and there are some things that Chrono does that DateTime doesn't. Sadly, there doesn't seem to be any interop between the two, so one will have to hand-convert Chrono's durations into DateType's equivalent.

这篇关于Boost.Chrono主场迎战的Boost.Date_Time的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆