title: How to convert number of days to hours using python date format string and strptime function?
body: <p>I'm working with dates retrieved from a mongoDB however, <strong>they are not all in the same format</strong>. They come in 3 different formats:</p>
  
  <pre><code>1. '%H:%M:%S' (Hours:Minutes:Seconds)
  2. '%H:%M:%S.f' (Hours:Minutes:Seconds:Milliseconds)
  3. Days.Hours:Minutes:Seconds:Milliseconds
  </code></pre>
  
  <p>I want to calculate the total time for all records from the database. The dates are stored in string format so I'm using the strptime function to retrieve a time object, then make a timedelta using that time object so i can add it all up:</p>
  
  <pre><code>formats = ('%H:%M:%S', '%%H:%M:%S.f', &lt;3rd format here&gt;)
  for db_item in db_collection:
      for fmt in formats:
         try:
             temp = datetime.strptime(db_item, fmt)
             temp = datetime.timedelta(hours=temp.hour, 
                                       minutes=temp.minute, 
                                       seconds=temp.minute,
                                       milliseconds=(temp.microsecond / 1000)
             return temp
         except ValueError as e:
  
  </code></pre>
  
  <p>Problem however is that the 3rd format I mentioned earlier specifies the n days before the '.', so I have no idea how to write a date format string for this format. </p>
  
  <p><strong>example</strong></p>
  
  <pre><code>1.01:20:40.97
  </code></pre>
  
  <p>means: 1 day (24 hours) , 1 Hour, 20 Minutes, 40 Seconds and 97 milliseconds</p>
  
  <p>what I'm aiming for:
  25:20:40.97 (24 hours + 1 hour)</p>
  
  <p>Is there a format that allows for this? or should I extract the n days seperatly, multiply by 24 and add manually later on?</p>