Skip to content

Commit 67862be

Browse files
committed
fix: time stamp
1 parent 2b0ad78 commit 67862be

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

app/src/main/java/com/github/jvsena42/floresta/presentation/ui/screens/home/HomeViewModel.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ class HomeViewModel(
6767
}
6868
} else {
6969
Log.d(TAG, "setup: Wallet does not exists")
70-
walletManager.createWallet()
71-
// walletManager.recoverWallet("bird unique ridge dose run problem scare label teach return inflict struggle")
70+
// walletManager.createWallet()
71+
walletManager.recoverWallet("bird unique ridge dose run problem scare label teach return inflict struggle")
7272
}
7373
}
7474

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package com.github.jvsena42.floresta.presentation.ui.screens.home
22

3+
import android.text.format.DateFormat
34
import com.github.jvsena42.floresta.domain.model.ChainPosition
45
import com.github.jvsena42.floresta.domain.model.TransactionDetails
56
import com.github.jvsena42.floresta.domain.model.TxType
6-
import java.text.SimpleDateFormat
7-
import java.util.Date
7+
import java.util.Calendar
88
import java.util.Locale
99

1010
data class TransactionVM(
@@ -16,13 +16,13 @@ data class TransactionVM(
1616

1717
fun TransactionDetails.toTransactionVM() = TransactionVM(
1818
title = this.txid,
19-
date = if (this.chainPosition is ChainPosition.Confirmed) convertMillisecondsToDateString(this.chainPosition.timestamp.toLong()) else "",
19+
date = if (this.chainPosition is ChainPosition.Confirmed) this.chainPosition.timestamp.timestampToString() else "",
2020
amount = (if (txType == TxType.RECEIVE) this.received.toSat() else this.sent.toSat()).toString(),
2121
isReceived = txType == TxType.RECEIVE
2222
)
2323

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

0 commit comments

Comments
 (0)