Skip to content

Commit

Permalink
fix: time stamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jvsena42 committed Oct 28, 2024
1 parent 2b0ad78 commit 67862be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ class HomeViewModel(
}
} else {
Log.d(TAG, "setup: Wallet does not exists")
walletManager.createWallet()
// walletManager.recoverWallet("bird unique ridge dose run problem scare label teach return inflict struggle")
// walletManager.createWallet()
walletManager.recoverWallet("bird unique ridge dose run problem scare label teach return inflict struggle")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.jvsena42.floresta.presentation.ui.screens.home

import android.text.format.DateFormat
import com.github.jvsena42.floresta.domain.model.ChainPosition
import com.github.jvsena42.floresta.domain.model.TransactionDetails
import com.github.jvsena42.floresta.domain.model.TxType
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Calendar
import java.util.Locale

data class TransactionVM(
Expand All @@ -16,13 +16,13 @@ data class TransactionVM(

fun TransactionDetails.toTransactionVM() = TransactionVM(
title = this.txid,
date = if (this.chainPosition is ChainPosition.Confirmed) convertMillisecondsToDateString(this.chainPosition.timestamp.toLong()) else "",
date = if (this.chainPosition is ChainPosition.Confirmed) this.chainPosition.timestamp.timestampToString() else "",
amount = (if (txType == TxType.RECEIVE) this.received.toSat() else this.sent.toSat()).toString(),
isReceived = txType == TxType.RECEIVE
)

private fun convertMillisecondsToDateString(milliseconds: Long): String {
val date = Date(milliseconds)
val format = SimpleDateFormat("dd/MM/yyyy HH:mm", Locale.getDefault())
return format.format(date)
fun ULong.timestampToString(): String {
val calendar = Calendar.getInstance(Locale.ENGLISH)
calendar.timeInMillis = (this * 1000u).toLong()
return DateFormat.format("MMMM d yyyy HH:mm", calendar).toString()
}

0 comments on commit 67862be

Please sign in to comment.