Files
news.gitea.happylizard.me/bin/gems/console-1.29.3/lib/console/clock.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

36 lines
618 B
Ruby

# frozen_string_literal: true
# Released under the MIT License.
# Copyright, 2021-2022, by Samuel Williams.
module Console
module Clock
def self.formatted_duration(duration)
if duration < 60.0
return "#{duration.round(2)}s"
end
duration /= 60.0
if duration < 60.0
return "#{duration.floor}m"
end
duration /= 60.0
if duration < 24.0
return "#{duration.floor}h"
end
duration /= 24.0
return "#{duration.floor}d"
end
# Get the current elapsed monotonic time.
def self.now
::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
end
end
end