class Vermillion::Helper::Time

Public Class Methods

formatted(time = nil) click to toggle source

Use the following format for a given timestamp: “d/m/y @ H:M:S AM/PM” Params:

time

Optional time value, uses the current time if not provided, to format

# File lib/client/helper/time.rb, line 27
def self.formatted(time = nil)
  time = ::Time.now if time.nil?
  time.strftime("%e/%-m/%Y @ %I:%M:%S%P")
end
human_readable(start, finish) click to toggle source

Human readable strings to represent the length between two time objects Params:

start

Start time object

finish

End time object

# File lib/client/helper/time.rb, line 8
def self.human_readable(start, finish)
  seconds = finish.to_f - start.to_f

  if seconds < 60
    "No time at all!"
  else
    minutes = (seconds / 60).round(1)
    if minutes < 1
      "#{minutes} minute"
    else
      "#{minutes} minutes"
    end
  end
end