mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 20:31:02 -05:00
Fix build time zone in about screen
And slight cleanup
This commit is contained in:
parent
d77f2f429d
commit
aed53d3bdc
2 changed files with 19 additions and 12 deletions
|
@ -55,8 +55,10 @@ import tachiyomi.presentation.core.icons.Reddit
|
||||||
import tachiyomi.presentation.core.icons.X
|
import tachiyomi.presentation.core.icons.X
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
|
import java.time.Instant
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.time.ZoneId
|
import java.time.ZoneId
|
||||||
|
import java.time.ZonedDateTime
|
||||||
import java.time.format.DateTimeFormatter
|
import java.time.format.DateTimeFormatter
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
|
|
||||||
|
@ -269,11 +271,15 @@ object AboutScreen : Screen() {
|
||||||
|
|
||||||
internal fun getFormattedBuildTime(): String {
|
internal fun getFormattedBuildTime(): String {
|
||||||
return try {
|
return try {
|
||||||
val df = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm'Z'", Locale.US)
|
LocalDateTime.ofInstant(
|
||||||
.withZone(ZoneId.of("UTC"))
|
Instant.parse(BuildConfig.BUILD_TIME),
|
||||||
val buildTime = LocalDateTime.from(df.parse(BuildConfig.BUILD_TIME))
|
ZoneId.systemDefault(),
|
||||||
|
)
|
||||||
buildTime!!.toDateTimestampString(UiPreferences.dateFormat(Injekt.get<UiPreferences>().dateFormat().get()))
|
.toDateTimestampString(
|
||||||
|
UiPreferences.dateFormat(
|
||||||
|
Injekt.get<UiPreferences>().dateFormat().get(),
|
||||||
|
),
|
||||||
|
)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
BuildConfig.BUILD_TIME
|
BuildConfig.BUILD_TIME
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.text.SimpleDateFormat
|
import java.time.LocalDateTime
|
||||||
import java.util.TimeZone
|
import java.time.ZoneOffset
|
||||||
import java.util.Date
|
import java.time.format.DateTimeFormatter
|
||||||
|
|
||||||
// Git is needed in your system PATH for these commands to work.
|
// Git is needed in your system PATH for these commands to work.
|
||||||
// If it's not installed, you can return a random value as a workaround
|
// If it's not installed, you can return a random value as a workaround
|
||||||
|
@ -16,10 +16,11 @@ fun Project.getGitSha(): String {
|
||||||
// return "1"
|
// return "1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val BUILD_TIME_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||||
|
|
||||||
|
@Suppress("UnusedReceiverParameter")
|
||||||
fun Project.getBuildTime(): String {
|
fun Project.getBuildTime(): String {
|
||||||
val df = SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
|
return LocalDateTime.now(ZoneOffset.UTC).format(BUILD_TIME_FORMATTER)
|
||||||
df.timeZone = TimeZone.getTimeZone("UTC")
|
|
||||||
return df.format(Date())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.runCommand(command: String): String {
|
fun Project.runCommand(command: String): String {
|
||||||
|
|
Loading…
Reference in a new issue