mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(time): Centralize time handling with kotlinx-datetime (#4545)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
da04448dee
commit
5ca2ab4695
86 changed files with 993 additions and 663 deletions
|
|
@ -31,10 +31,12 @@ import org.meshtastic.core.model.MessageStatus
|
|||
import org.meshtastic.core.model.MyNodeInfo
|
||||
import org.meshtastic.core.model.NodeInfo
|
||||
import org.meshtastic.core.model.Position
|
||||
import org.meshtastic.core.model.util.nowMillis
|
||||
import org.meshtastic.core.model.util.toDate
|
||||
import org.meshtastic.core.model.util.toInstant
|
||||
import org.meshtastic.core.service.IMeshService
|
||||
import org.meshtastic.proto.PortNum
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
import kotlin.random.Random
|
||||
|
||||
|
|
@ -118,7 +120,7 @@ class MeshServiceViewModel : ViewModel() {
|
|||
bytes = text.encodeToByteArray().toByteString(),
|
||||
dataType = PortNum.TEXT_MESSAGE_APP.value,
|
||||
from = DataPacket.ID_LOCAL,
|
||||
time = System.currentTimeMillis(),
|
||||
time = nowMillis,
|
||||
id = service.packetId,
|
||||
status = MessageStatus.UNKNOWN,
|
||||
hopLimit = 3,
|
||||
|
|
@ -144,7 +146,7 @@ class MeshServiceViewModel : ViewModel() {
|
|||
bytes = "Special Payload for ${portNum.name}".encodeToByteArray().toByteString(),
|
||||
dataType = portNum.value,
|
||||
from = DataPacket.ID_LOCAL,
|
||||
time = System.currentTimeMillis(),
|
||||
time = nowMillis,
|
||||
id = service.packetId,
|
||||
status = MessageStatus.UNKNOWN,
|
||||
hopLimit = 3,
|
||||
|
|
@ -341,7 +343,8 @@ class MeshServiceViewModel : ViewModel() {
|
|||
}
|
||||
|
||||
private fun addToLog(entry: String) {
|
||||
val timestamp = SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(Date())
|
||||
val date = nowMillis.toInstant().toDate()
|
||||
val timestamp = SimpleDateFormat("HH:mm:ss", Locale.getDefault()).format(date)
|
||||
val logEntry = "[$timestamp] $entry"
|
||||
Log.d(TAG, "Log: $logEntry")
|
||||
@Suppress("MagicNumber")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue