HMS now takes ints and has totalseconds and tostring functions
This commit is contained in:
		
							parent
							
								
									2c62e13caa
								
							
						
					
					
						commit
						7046a2a985
					
				
					 2 changed files with 14 additions and 7 deletions
				
			
		|  | @ -1,4 +1,15 @@ | ||||||
| package be.ugent.sel.studeez.data.local.models.timer_functional | package be.ugent.sel.studeez.data.local.models.timer_functional | ||||||
| 
 | 
 | ||||||
| data class HoursMinutesSeconds(val hours: String, val minutes: String, val seconds: String | data class HoursMinutesSeconds(val hours: Int, val minutes: Int, val seconds: Int) { | ||||||
| ) | 
 | ||||||
|  |     fun getTotalSeconds(): Int { | ||||||
|  |         return hours * 60 * 60 + minutes * 60 + seconds | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     override fun toString(): String { | ||||||
|  |         val hoursString = hours.toString().padStart(2, '0') | ||||||
|  |         val minutesString = minutes.toString().padStart(2, '0') | ||||||
|  |         val secondsString = seconds.toString().padStart(2, '0') | ||||||
|  |         return "$hoursString : $minutesString : $secondsString" | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | @ -17,11 +17,7 @@ class Time(initialTime: Int) { | ||||||
|         val minutes: Int = (time / (60)) % 60 |         val minutes: Int = (time / (60)) % 60 | ||||||
|         val seconds: Int = time % 60 |         val seconds: Int = time % 60 | ||||||
| 
 | 
 | ||||||
|         return HoursMinutesSeconds( |         return HoursMinutesSeconds(hours, minutes, seconds) | ||||||
|             hours.toString().padStart(2, '0'), |  | ||||||
|             minutes.toString().padStart(2, '0'), |  | ||||||
|             seconds.toString().padStart(2, '0') |  | ||||||
|         ) |  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| } | } | ||||||
		Reference in a new issue
	
	 lbarraga
						lbarraga