2017-08-17 86 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的時間,你應該可以單獨添加小時/分鐘/秒等等,或者你可以將時間轉換爲自時代以來的時間,並以這種方式進行計算。