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
targetSdk = 35
versionCode = 1
versionName = "Alpha 0.5.1"
versionName = "Alpha 0.5.2"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

View File

@ -1,6 +1,7 @@
package com.github.nacabaro.vbhelper.screens.scanScreen.converters
import android.icu.util.Calendar
import android.icu.util.TimeZone
import android.util.Log
import androidx.activity.ComponentActivity
import com.github.cfogrady.vbnfc.be.BENfcCharacter
@ -243,16 +244,23 @@ class ToNfcConverter(
.getTransformationHistory(characterId)!!
.map {
val date = Date(it.transformationDate)
val calendar = android.icu.util.GregorianCalendar()
val calendar = android.icu.util.GregorianCalendar(TimeZone.getTimeZone("UTC"))
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(
toCharIndex = it.monIndex.toUByte(),
year = calendar
.get(Calendar.YEAR)
.toUShort(),
month = calendar
.get(Calendar.MONTH)
month = (calendar
.get(Calendar.MONTH) + 1)
.toUByte(),
day = calendar
.get(Calendar.DAY_OF_MONTH)