Is there a library to work with historical (big) dates (eg, 11,043 BC)? Get century, millennium?
-
6I'm curious: what is it that you're working on?– Jay RiggsCommented Apr 10, 2013 at 4:01
-
What library functions are you after? Standard ones like AddDays(), DateDiff() and formatted ToString()? What precision do you need - days, seconds, milliseconds? Do you care about names of days of the week? If all you want is get century or millennium then divide by 100 or 1000 and be done with it, if you want more then figure out what it is, because if it's something very specific you're probably better off doing it yourself.– Mike TrusovCommented Apr 10, 2013 at 4:41
-
2I don't think there's really such a thing as "dates" for such distant times in the past; there was no official calendar in place at the time. If you want to just extend the Gregorian calendar back, you can easily do so yourself without any library help, but it will mismatch the "official" dates prior to the adoption of the Gregorian calendar.– R.. GitHub STOP HELPING ICECommented Apr 10, 2013 at 5:41
-
Certainly, if you are going back that far Century and Millenium have very little meaning, but if you want it, then its a very very simple calculation you can just do with a Property. Just set the get value to the Math.Floor(date/1000) + 1 and Math.Floor(Date/100) + 1 and maybe use negative values as BC and positive as AD and Modulate it? Unless you want more interactivity.– Ryan DurrantCommented Apr 10, 2013 at 17:59
-
There are special calendars for working with (pre-)historical astronomical data. I can't recall the name right now, but I would choose that. If the game shows the night time sky, it could even skew the zodiac realistically. :-)– Prof. FalkenCommented Apr 11, 2013 at 7:29
2 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.
Have a look at dateutil
.
The recurrence rules and relative deltas are what you want.
-
Isn't that a Python tool? I think he/she is looking for a C/C++ interface Commented May 30, 2013 at 7:20