Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

library to work with historical (big) dates and time (eg, 11,043 BC)?

Tags:

c++

c

Is there a library to work with historical (big) dates (eg, 11,043 BC)? Get century, millennium?

like image 761
manking Avatar asked Apr 10 '13 03:04

manking


1 Answers

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.

like image 52
cfa45ca55111016ee9269f0a52e771 Avatar answered Nov 05 '22 22:11

cfa45ca55111016ee9269f0a52e771