mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	A field for storing periods of time - modeled in Python by timedelta. It is stored in the native interval data type on PostgreSQL and as a bigint of microseconds on other backends. Also includes significant changes to the internals of time related maths in expressions, including the removal of DateModifierNode. Thanks to Tim and Josh in particular for reviews.
		
			
				
	
	
		
			22 lines
		
	
	
		
			519 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			519 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| """Version of str(timedelta) which is not English specific."""
 | |
| 
 | |
| 
 | |
| def duration_string(duration):
 | |
|     days = duration.days
 | |
|     seconds = duration.seconds
 | |
|     microseconds = duration.microseconds
 | |
| 
 | |
|     minutes = seconds // 60
 | |
|     seconds = seconds % 60
 | |
| 
 | |
|     hours = minutes // 60
 | |
|     minutes = minutes % 60
 | |
| 
 | |
|     string = '{:02d}:{:02d}:{:02d}'.format(hours, minutes, seconds)
 | |
|     if days:
 | |
|         string = '{} '.format(days) + string
 | |
|     if microseconds:
 | |
|         string += '.{:06d}'.format(microseconds)
 | |
| 
 | |
|     return string
 |