Skip to content

Commit

Permalink
fix: duration when seconds is multiple of 3600
Browse files Browse the repository at this point in the history
Fixes: #826
  • Loading branch information
danirod committed Nov 26, 2023
1 parent b750561 commit 05b3632
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/components/six/explorer/playlist_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ def initialize(playlist:)
end

def duration
parts = ActiveSupport::Duration.build(total_seconds).parts
minutes = t('.minutes', count: parts[:minutes])
return minutes if parts[:hours].blank?
duration = ActiveSupport::Duration.build(total_seconds)

hours = t('.hours', count: parts[:hours])
[hours, minutes].join(', ')
minutes = duration.in_minutes.to_i % 60
hours = duration.in_hours.to_i

[
hours.positive? ? t('.hours', count: hours) : nil,
minutes.positive? ? t('.minutes', count: minutes) : nil
].compact.join(', ')
end

private
Expand Down

0 comments on commit 05b3632

Please sign in to comment.