Toordinal method of datetime class in Python

Method Name:

toordinal

 

Method Signature:

toordinal()

 

Method Overview:

  • Returns the proleptic Gregorian ordinal of a datetime instance.

 

  • Proleptic Gregorian ordinal provides the number of days elapsed from the date 01/Jan/0001.

 

  • The ordinal is called Proleptic since the Gregorian calendar itself is followed from October 1582.

 

Example:

 

import datetime

 

veryFirstDay        = datetime.datetime(1,1,1,0,0,0,0)

prolepticOrdinal    = veryFirstDay.toordinal()

 

print("Proleptic Ordinal for very 1st day: {}".format(prolepticOrdinal))

 

daVinciBirthDay        = datetime.datetime(1452,4,15,0,0,0,0)

 

prolepticOrdinal        = daVinciBirthDay.toordinal()

 

print("Proleptic Ordinal for Da Vinci's birth day: {}".format(prolepticOrdinal))

 

Output:

Proleptic Ordinal for very 1st day: 1

Proleptic Ordinal for Da Vinci's birth day: 530072

 


Copyright 2024 © pythontic.com