GALIAF95
GALIAF95

Reputation: 637

How to create negative datetime in python 2.7

I need to insert into mongo db some BC dates but I cant create datetime with negative value like datetime.datetime(-2000, 2, 1), but in mongodb it is possible to do with IsoDate, so how can i create negative dates in python? I'm currently using python 2.7, and i do it on purpouse, for the project.

Upvotes: 3

Views: 892

Answers (1)

aa333
aa333

Reputation: 2576

Python 2.7's datetime library can only handle AD dates. If you need to go back further than that you will have to look at other libraries such as the Time class in Astropy or date in datautil.

Upvotes: 2

Related Questions