File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -429,9 +429,15 @@ def microseconds(self):
429429    # Instance methods 
430430    def  total_seconds (self ):
431431        """Return the total number of seconds contained in the duration.""" 
432-         return  (
433-             (self ._days  *  86400  +  self ._seconds ) *  10  **  6  +  self ._microseconds 
434-         ) /  10  **  6 
432+         # If the duration is less than a threshold duration, and microseconds 
433+         # is nonzero, then the result is a float.  Otherwise, the result is a 
434+         # (possibly long) integer.  This differs from standard Python where the 
435+         # result is always a float, because the precision of CircuitPython 
436+         # floats is considerably smaller than on standard Python. 
437+         seconds  =  self ._days  *  86400  +  self ._seconds 
438+         if  self ._microseconds  !=  0  and  abs (seconds ) <  (1  <<  21 ):
439+             seconds  +=  self ._microseconds  /  10  **  6 
440+         return  seconds 
435441
436442    def  __repr__ (self ):
437443        args  =  []
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments