|
|
|
|
@ -96,3 +96,25 @@ fun Date.getFormattedDuration(toDate: Date) : String { |
|
|
|
|
|
|
|
|
|
return "$hoursStr:$minutesStr" |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Return the date of the beginning of the current date |
|
|
|
|
fun Date.startOfTheDay() : Date { |
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
calendar.time = this |
|
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 0) |
|
|
|
|
calendar.set(Calendar.MINUTE, 0) |
|
|
|
|
calendar.set(Calendar.SECOND, 0) |
|
|
|
|
calendar.set(Calendar.MILLISECOND, 0) |
|
|
|
|
return calendar.time |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Return the date of the end of the current date |
|
|
|
|
fun Date.endOfTheDay() : Date { |
|
|
|
|
val calendar = Calendar.getInstance() |
|
|
|
|
calendar.time = this |
|
|
|
|
calendar.set(Calendar.HOUR_OF_DAY, 23) |
|
|
|
|
calendar.set(Calendar.MINUTE, 59) |
|
|
|
|
calendar.set(Calendar.SECOND, 59) |
|
|
|
|
calendar.set(Calendar.MILLISECOND, 999) |
|
|
|
|
return calendar.time |
|
|
|
|
} |