forked from penguin86/luna-tracker
DateUtils: make duration rounded up to minutes
This commit is contained in:
@@ -9,10 +9,14 @@ import java.util.Date
|
|||||||
class DateUtils {
|
class DateUtils {
|
||||||
companion object {
|
companion object {
|
||||||
/**
|
/**
|
||||||
* Format time duration in seconds as e.g. "2 hours, 1 min".
|
* Format time duration in seconds as e.g. "2 hours, 1 min", rounded up to minutes.
|
||||||
* Used for the duration to the next/previous event in the event details dialog.
|
* Used for the duration to the next/previous event in the event details dialog.
|
||||||
*/
|
*/
|
||||||
fun formatTimeDuration(context: Context, secondsDiff: Long): String {
|
fun formatTimeDuration(context: Context, secondsDiff: Long): String {
|
||||||
|
return formatTimeDurationExact(context, 60L + secondsDiff - (secondsDiff % 60L))
|
||||||
|
}
|
||||||
|
|
||||||
|
fun formatTimeDurationExact(context: Context, secondsDiff: Long): String {
|
||||||
var seconds = secondsDiff
|
var seconds = secondsDiff
|
||||||
|
|
||||||
val years = (seconds / (365 * 24 * 60 * 60F)).toLong()
|
val years = (seconds / (365 * 24 * 60 * 60F)).toLong()
|
||||||
|
|||||||
Reference in New Issue
Block a user