2017-08-17 68 views
0

在我的CentOS 6.9环境下,boost-devel指的是Boost 1.4 .0库。Boost 1.41.0:boost :: locale的替代方案?

的问题是,升压:语言环境不适用于相对于一个特定的时区我的日期的计算,如升压:语言环境似乎来加速1.4 0.0。

是否有替代做类似1.41(或替代Boost)的事情?

// adding a day to now with timezone in mind 
std::locale::global(...a specific locale...); 
date_time now; 
now = now + period:day(); 
+0

下面是另一个时区库,它非常完整:https://howardhinnant.github.io/date/tz.html但是,我不知道它是否适用于旧环境。它需要C++ 11的''。以下是示例代码,显示在夏令时间更改期间的任意时区中将当地时间添加到1天的时间:https://github.com/HowardHinnant/date/wiki/Examples-and-Recipes#local_arithmetic –

回答

0

您可能能够在CentOS 6使用std ::区域提供C++ 98

看到这里解析本地格式的时间到的std ::时间的例子:http://www.cplusplus.com/reference/locale/time_get/get_date/

一旦你有了std :: time的时间,你应该可以单独添加小时/分钟/秒等等,或者你可以将时间转换为自时代以来的时间,并以这种方式进行计算。

相关问题