Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fun timeToString(timestampMs: Long) has something wrong #4378

Closed
Jeffyang2017 opened this issue Feb 28, 2024 · 3 comments
Closed

fun timeToString(timestampMs: Long) has something wrong #4378

Jeffyang2017 opened this issue Feb 28, 2024 · 3 comments
Assignees
Labels
bug Something isn't working reproduced

Comments

@Jeffyang2017
Copy link

Describe the bug
There is a mistake for hour. It should be val hours = minutes / 60 rather than val hours = minutes / 24. The same to val h = hours % 24.

Path: chat\shared\src\commonMain\kotlin\currentTime.common.kt

fun timeToString(timestampMs: Long): String {
val seconds = timestampMs
val minutes = seconds / 1000 / 60
val hours = minutes / 60
// val hours = minutes / 24

val m = minutes % 60
val h = hours % 60

// val h = hours % 24

val mm = if (m < 10) {
    "0$m"
} else {
    m.toString()
}
val hh = if (h < 10) {
    "0$h"
} else {
    h.toString()
}
return "$hh:$mm"

}

expect fun timestampMs(): Long

@Jeffyang2017 Jeffyang2017 added bug Something isn't working submitted labels Feb 28, 2024
@dima-avdeev-jb
Copy link
Contributor

Thanks! I will fix it!

@Jeffyang2017
Copy link
Author

Sorry, val h = hours % 60 is wrong by me. Just correct val hours = minutes / 60.

@dima-avdeev-jb dima-avdeev-jb self-assigned this Feb 28, 2024
dima-avdeev-jb added a commit that referenced this issue Feb 28, 2024
Fix time of message in ChatApp sample.
Added library kotlinx-datetime.

It resolves issue:
 - #4378
@dima-avdeev-jb
Copy link
Contributor

@Jeffyang2017 fixed. Added kotlinx-datetime library

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working reproduced
Projects
None yet
Development

No branches or pull requests

2 participants