osem-fcy/app/helpers/date_time_currency_helper.rb
2018-03-17 16:38:59 +02:00

41 lines
879 B
Ruby

module DateTimeCurrencyHelper
##
# Includes functions related to date or time manipulations
##
##
# Gets an EventType object, and returns its length in timestamp format (HH:MM)
# ====Gets
# * +Integer+ -> 30
# ====Returns
# * +String+ -> "00:30"
def length_timestamp(length)
[length / 60, length % 60].map { |t| t.to_s.rjust(2, '0') }.join(':')
end
##
# Gets a datetime object
# ====Returns
# * +String+ -> formated datetime object
def format_datetime(obj)
return unless obj
obj.strftime('%Y-%m-%d %H:%M')
end
def show_time(length)
return '0 h 0 min' if length.blank?
h, min = length.divmod(60)
if h == 0
"#{min.round} min"
elsif min == 0
"#{h} h"
else
"#{h} h #{min.round} min"
end
end
def currencies
default_currencies = YAML::load(ENV['OSEM_DEFAULT_CURRENCIES'])
end
end