posts: fix incorrect duration shown for certain videos.
Fix thumbnails incorrectly showing a duration of "0:00" when a video had a duration between 59.5 seconds and 60.0 seconds. This happened because of incorrect rounding - the seconds value was rounded up, but the minutes value wasn't. Examples: https://danbooru.donmai.us/posts?tags=duration:59.5...60.0+status:any
This commit is contained in:
@@ -103,9 +103,10 @@ module ApplicationHelper
|
||||
end
|
||||
|
||||
def duration_to_hhmmss(seconds)
|
||||
seconds = seconds.round
|
||||
hh = seconds.div(1.hour).to_s
|
||||
mm = seconds.div(1.minute).to_s
|
||||
ss = "%.2d" % (seconds.round % 1.minute)
|
||||
ss = "%.2d" % (seconds % 1.minute)
|
||||
|
||||
if seconds >= 1.hour
|
||||
"#{hh}:#{mm}:#{ss}"
|
||||
|
||||
Reference in New Issue
Block a user