code: def total_seconds(td):
    
    secs = td.seconds + td.days * 24 * 3600
    if td.microseconds:
      secs += 1
    return secs
docs: 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.