BC日期在Python [英] BC dates in Python

查看:259
本文介绍了BC日期在Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个使用Python构建应用程序,需要广泛处理BC日期(在DB中存储和检索,进行计算)。大多数日期会有各种各样的不确定性,如大约2000BC。



我知道Python的datetime库仅处理1 AD的日期。



到目前为止,我只发现了 FlexiDate 。有没有其他选择?



编辑:最好的方法可能是将它们存储为字符串(以String作为基本数据类型)和 - 建议 - 有一个定制的datetime类,可以使它的一些数字感觉。对于大多数人来说,日期只能包含一年。有一些有趣的问题要解决,像早期的500BC,1600BC和1500BC之间,1800BC之前。

解决方案

它是一个有趣的问题,似乎这样的一个类不存在(re @joel Cornett评论)如果你只在几年内工作,只会简化你的类来处理整数而不是日历日期 - 你可以使用一个字典文本描述(10 BC)与整数值(-10)
编辑:我googled这个:



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


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".

解决方案

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/

这篇关于BC日期在Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆