Standard way to express a date in a real number?
Steven Taschuk
staschuk at telusplanet.net
Wed Apr 16 22:20:40 EDT 2003
Quoth John Roth:
> "Alex Martelli" <aleax at aleax.it> wrote in message
> news:9t8na.27736$T34.825154 at news2.tin.it...
[...]
> > 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.
So fix it:
>>> _epoch = datetime.date(-4711, 1, 1)
>>> def date2ordinal(date):
... return date.toordinal() - _epoch.toordinal()
--
Steven Taschuk staschuk at telusplanet.net
"I may be wrong but I'm positive." -- _Friday_, Robert A. Heinlein
More information about the Python-list
mailing list