[Python-ideas] Date/time literals

Tim Peters tim.peters at gmail.com
Tue Jun 1 20:12:10 CEST 2010

[Marcos Bonci]
> ...
> But I still don't understand why datetime.datetime.toordinal returns
> an int that truncates time information. Is this deliberate?

That it does exactly what it's documented to do is a clue about that ;-)

As the module docs say, the notion of "ordinal" was deliberately
defined in this way:

    This matches the definition of the “proleptic Gregorian” calendar in
    Dershowitz and Reingold’s book "Calendrical Calculations", where
    it’s the base calendar for all computations. See the book for
    algorithms for converting between proleptic Gregorian ordinals and
    many other calendar systems.

That's the primary use case we had in mind for date & datetime
ordinals.  Indeed, the meaning of "ordinal" is "an integer indicating
position in a sequence".

More information about the Python-ideas mailing list