Search code examples
pythondate

BC dates in Python


I'm setting out to build an app with Python that will need to handle BC dates extensively (store and retrieve in DB, do calculations). Most dates will be of various uncertainties, like "around 2000BC".

I know Python's datetime library only handles dates from 1 AD.

So far I only found FlexiDate. Are there any other options?

EDIT: The best approach would probably be to store them as strings (have String as the basic data type) and -as suggested- have a custom datetime class which can make some numerical sense of it. For the majority it looks like dates will only consist of a year. There are some interesting problems to solve like "early 500BC", "between 1600BC and 1500BC", "before 1800BC".


Solution

  • Its an interesting question, it seems odd that such a class does not exist yet (re @joel Cornett comment) If you only work in years only it would simplify your class to handling integers rather than calendar dates - you could possibly use a dictionary with the text description (10 BC) against and integer value (-10) EDIT: I googled this:

    http://code.activestate.com/lists/python-list/623672/