3 Commits

Author SHA1 Message Date
f3fb584ec2 activity_setting: fine tune layout style 2025-09-29 19:12:46 +02:00
f38b889248 add signature setting
For multiple users it helps to
keep track about who did what.
2025-09-29 19:12:42 +02:00
301e8d0476 DateUtils: move event details formatting to DateUtils
Also display second as 0 since it is easier
to read and does not have meaning for the user.
2025-09-29 17:50:06 +02:00

View File

@@ -1,7 +1,6 @@
package utils package utils
import android.content.Context import android.content.Context
import android.os.Build
import android.text.format.DateFormat import android.text.format.DateFormat
import it.danieleverducci.lunatracker.R import it.danieleverducci.lunatracker.R
import java.util.Date import java.util.Date
@@ -108,19 +107,15 @@ class DateUtils {
} }
/** /**
* Format time as localized string without seconds. E.g. "Sept 18, 2025, 03:36 PM". * Format time as localized string. E.g. "28 Sept 03:36:00".
* The seconds are set to 0 since they are distracting and not relevant.
* Used in the event detail dialog. * Used in the event detail dialog.
*/ */
fun formatDateTime(unixTime: Long): String { fun formatDateTime(unixTime: Long): String {
val date = Date(unixTime * 1000) val roundedUnixTime = unixTime - (unixTime % 60)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { val date = Date(roundedUnixTime * 1000)
val dateFormat = android.icu.text.DateFormat.getDateTimeInstance(android.icu.text.DateFormat.RELATIVE_SHORT, android.icu.text.DateFormat.SHORT) val dateFormat = java.text.DateFormat.getDateTimeInstance()
return dateFormat.format(date) return dateFormat.format(date)
} else {
// fallback
val dateFormat = java.text.DateFormat.getDateTimeInstance()
return dateFormat.format(date)
}
} }
} }
} }