Fixed date issues with TransformationHistory

This commit is contained in:
Nacho 2025-09-02 04:54:08 +02:00
parent f8ec899335
commit 1a6753d2aa
2 changed files with 12 additions and 4 deletions

View File

@ -15,7 +15,7 @@ android {
minSdk = 28 minSdk = 28
targetSdk = 35 targetSdk = 35
versionCode = 1 versionCode = 1
versionName = "Alpha 0.5.1" versionName = "Alpha 0.5.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
} }

View File

@ -1,6 +1,7 @@
package com.github.nacabaro.vbhelper.screens.scanScreen.converters package com.github.nacabaro.vbhelper.screens.scanScreen.converters
import android.icu.util.Calendar import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.util.Log import android.util.Log
import androidx.activity.ComponentActivity import androidx.activity.ComponentActivity
import com.github.cfogrady.vbnfc.be.BENfcCharacter import com.github.cfogrady.vbnfc.be.BENfcCharacter
@ -243,16 +244,23 @@ class ToNfcConverter(
.getTransformationHistory(characterId)!! .getTransformationHistory(characterId)!!
.map { .map {
val date = Date(it.transformationDate) val date = Date(it.transformationDate)
val calendar = android.icu.util.GregorianCalendar() val calendar = android.icu.util.GregorianCalendar(TimeZone.getTimeZone("UTC"))
calendar.time = date calendar.time = date
Log.d(
"TransformationHistory",
"Year: ${calendar.get(Calendar.YEAR)}, " +
"Month: ${calendar.get(Calendar.MONTH) + 1}, " +
"Day: ${calendar.get(Calendar.DAY_OF_MONTH)}"
)
NfcCharacter.Transformation( NfcCharacter.Transformation(
toCharIndex = it.monIndex.toUByte(), toCharIndex = it.monIndex.toUByte(),
year = calendar year = calendar
.get(Calendar.YEAR) .get(Calendar.YEAR)
.toUShort(), .toUShort(),
month = calendar month = (calendar
.get(Calendar.MONTH) .get(Calendar.MONTH) + 1)
.toUByte(), .toUByte(),
day = calendar day = calendar
.get(Calendar.DAY_OF_MONTH) .get(Calendar.DAY_OF_MONTH)