14

是否有图书馆可以处理历史(大)日期(例如,公元前 11,043 年)?得到世纪,千年?

4

2 回答 2

2

For dates and times in general, there's the standard C++11 time classes, and the Glib library offers the GDateTime class, with a C++ binding Glib::DateTime in glibmm. Maybe the Boost libraries have a similar interface too.

If you need historical dates like when there were dinosaurs, you can write your own simple class (unless one of the options I mentioned are good enough, in which case computing the century or millenium by yourself is very easy).

Edit: Most implementations represent time as the number of second or microseconds in Unix time, i.e. since 1970, which means even a 64 bit integer may not be able to represent ancient times (you can try calculating or web-searching or reading on Wikipedia about these limits).

In this case a nice solution can be to use a separate AncientTime class which has just a year, and anything else you need, like month/day/hour can be imlemented by using a simple standrd DateTime class, in which you may ignore the year or keep it normalized to 0 through a thin wrapper.

于 2013-05-30T07:20:14.130 回答
0

看看dateutil

重复规则相对增量是您想要的。

于 2013-04-11T05:17:26.403 回答