[Bug]: Rounding Display Error in Listen Time #2474

Closed
opened 2026-04-25 00:07:31 +02:00 by adam · 0 comments
Owner

Originally created by @daneroo on GitHub (Jan 10, 2025).

What happened?

In the Audiobookshelf Year In Review, there was a time at which the App reported
"Listening Time" as "44d23h60m", and a few seconds later it reported "Listening Time" as "45d", which was more correct I think

Correct Display Bug Display
Year In Review OK Year In Review BUG

What did you expect to happen?

The rounded value should not display "60m"

Steps to reproduce the issue

Not sure how to reproduce with the UI, as it would depend on "injecting" a value for Total Listen'd time!

Having looked at the code for the YearInReview.vue -> client/plugin/utils.js:Vue.prototype.$elapsedPrettyExtended

The problem seems to be in the rounding behaviour of the $elapsedPrettyExtended function.

This functions displays seconds in terms of days,hours,minutes.

Here is a table of it's current behaviour, and what I think the correct behaviour should be

Input Original Function Fixed Function Status
0d 0h 0m 0s
0d 0h 0m 29.9s 1m modified
0d 0h 0m 30s 1m modified
0d 23h 59m 30s 23h 60m 1d modified
0d 1h 0m 29.51s 1h 1h 1m modified
0d 1h 0m 29.5s 1h 1h 1m modified
0d 1h 0m 29.49s 1h 1h
999d 23h 59m 30s 999d 23h 60m 1000d modified
44d 23h 59m 29s 44d 23h 59m 44d 23h 59m
44d 23h 59m 30s 44d 23h 60m 45d modified
44d 23h 59m 59s 44d 23h 60m 45d modified
44d 23h 59m 59.3s 44d 23h 60m 45d modified
44d 23h 59m 59.9s 45d 45d
45d 0h 0m 0s 45d 45d

Audiobookshelf version

v2.16.2

How are you running audiobookshelf?

Docker

What OS is your Audiobookshelf server hosted from?

Linux

If the issue is being seen in the UI, what browsers are you seeing the problem on?

None

Logs

No response

Additional Notes

I have code to reproduce the error and correct its behaviour.

I will attempt to create a PR to fix it. (I am new to the project)

Originally created by @daneroo on GitHub (Jan 10, 2025). ### What happened? In the Audiobookshelf Year In Review, there was a time at which the App reported "Listening Time" as "44d23h60m", and a few seconds later it reported "Listening Time" as "45d", which was more correct I think | Correct Display | Bug Display | |:---------------:|:-----------:| | <img src="https://github.com/user-attachments/assets/a883099f-5439-4f40-b3c2-3719241df498" width="200" alt="Year In Review OK"> | <img src="https://github.com/user-attachments/assets/bfa344a3-786d-4366-9eb0-0ccd88a274c7" width="200" alt="Year In Review BUG"> | ### What did you expect to happen? The rounded value should not display "60m" ### Steps to reproduce the issue Not sure how to reproduce with the UI, as it would depend on "injecting" a value for Total Listen'd time! Having looked at the code for the `YearInReview.vue` -> `client/plugin/utils.js:Vue.prototype.$elapsedPrettyExtended` The problem seems to be in the rounding behaviour of the `$elapsedPrettyExtended` function. This functions displays `seconds` in terms of days,hours,minutes. Here is a table of it's current behaviour, and what I think the correct behaviour should be | Input | Original Function | Fixed Function | Status | |-------------------|-------------------|----------------|----------| | 0d 0h 0m 0s | | | | | 0d 0h 0m 29.9s | | 1m | modified | | 0d 0h 0m 30s | | 1m | modified | | 0d 23h 59m 30s | 23h 60m | 1d | modified | | 0d 1h 0m 29.51s | 1h | 1h 1m | modified | | 0d 1h 0m 29.5s | 1h | 1h 1m | modified | | 0d 1h 0m 29.49s | 1h | 1h | | | 999d 23h 59m 30s | 999d 23h 60m | 1000d | modified | | 44d 23h 59m 29s | 44d 23h 59m | 44d 23h 59m | | | 44d 23h 59m 30s | 44d 23h 60m | 45d | modified | | 44d 23h 59m 59s | 44d 23h 60m | 45d | modified | | 44d 23h 59m 59.3s | 44d 23h 60m | 45d | modified | | 44d 23h 59m 59.9s | 45d | 45d | | | 45d 0h 0m 0s | 45d | 45d | | ### Audiobookshelf version v2.16.2 ### How are you running audiobookshelf? Docker ### What OS is your Audiobookshelf server hosted from? Linux ### If the issue is being seen in the UI, what browsers are you seeing the problem on? None ### Logs _No response_ ### Additional Notes I have code to reproduce the error and correct its behaviour. I will attempt to create a PR to fix it. (I am new to the project)
adam added the bug label 2026-04-25 00:07:31 +02:00
adam closed this issue 2026-04-25 00:07:32 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#2474