lib/rocket_job/rocket_job.rb in rocketjob-5.1.1 vs lib/rocket_job/rocket_job.rb in rocketjob-5.2.0.beta1
- old
+ new
@@ -24,23 +24,24 @@
end
# Returns a human readable duration from the supplied [Float] number of seconds
def self.seconds_as_duration(seconds)
return nil unless seconds
+
if seconds >= 86_400.0 # 1 day
"#{(seconds / 86_400).to_i}d #{Time.at(seconds).strftime('%-Hh %-Mm')}"
elsif seconds >= 3600.0 # 1 hour
- Time.at(seconds).strftime('%-Hh %-Mm')
+ Time.at(seconds).strftime("%-Hh %-Mm")
elsif seconds >= 60.0 # 1 minute
- Time.at(seconds).strftime('%-Mm %-Ss')
+ Time.at(seconds).strftime("%-Mm %-Ss")
elsif seconds >= 1.0 # 1 second
- format('%.3fs', seconds)
+ format("%.3fs", seconds)
else
duration = seconds * 1000
if defined? JRuby
"#{duration.to_i}ms"
else
- duration < 10.0 ? format('%.3fms', duration) : format('%.1fms', duration)
+ duration < 10.0 ? format("%.3fms", duration) : format("%.1fms", duration)
end
end
end
# private