Standard way to express a date in a real number?

John Roth johnroth at ameritech.net
Thu Apr 17 02:07:49 CEST 2003


"Alex Martelli" <aleax at aleax.it> wrote in message
news:9t8na.27736$T34.825154 at news2.tin.it...
> sdhyok wrote:
>
> > Tyler Eaves <tyler at cg1.org> wrote in message
> > news:<bEGma.462$8c4.82 at tornadotest1.news.pas.earthlink.net>...
> >> Nicola Mingotti wrote:
> >>
> >> > import time
> >> > t = time.time()
> >> > # t is the number you asked for
> >> >
> >> > If you want to know more about this look at
> >> > the "time" module .
> >> >
> >> >
> >> > bye.
> >>
> >> The problem is that you can only represent dates from 1970 -
> >> 2030-someting that way.
> >
> > So, this is not the solution I am seeking.
> > Better module to handle wider range of time?
>
> In Python 2.3, module datetime may serve your needs:
>
> >>> datetime.date(2303,4,16).toordinal()
> 840893
> >>> datetime.date(1303,4,16).toordinal()
> 475651

Unfortunately, this appears to be based off of 1AD or
some such. I usually want 4712BC as the base - in other
words, the astronomical Julian date.

> >>>
>
> Of course, dates before the Gregorian calendar's establishment
> (which happened in different years in different nations...!)
> will give somewhat arbitrary results, but apart from that you're
> all right.

Technically, it's called a proleptic Gregorian date, that is, a
date created according to the Gregorian calendar rules before
it was used historically.

> The result is an integer, but it's not hard to turn
> it into a float if that's what you desire for some reason or other.
>
>
> Alex
>






More information about the Python-list mailing list