def total_seconds ( td ) : secs = td . seconds + td . days * 24 * 3600 if td . microseconds : secs += 1 return secs
caculating seconds from number of days using datetime in python
convert a timedelta to seconds .
def total_seconds(td):
  """convert a timedelta to seconds.

  This is patterned after timedelta.total_seconds, which is only
  available in python 27.

  Args:
    td: a timedelta object.

  Returns:
    total seconds within a timedelta. Rounded up to seconds.
  """
  secs = td.seconds + td.days * 24 * 3600
  if td.microseconds:
    secs += 1
  return secs