class Dateutil
Some basic utils for handling date / time
Public Class Methods
new()
click to toggle source
# File lib/utils/date/date.rb, line 8 def initialize @prompt = TTY::Prompt.new end
Public Instance Methods
ask_date()
click to toggle source
# File lib/utils/date/date.rb, line 12 def ask_date Time.parse(@prompt.ask('Enter a date (Y/M/D):')) end
ask_end_date()
click to toggle source
# File lib/utils/date/date.rb, line 20 def ask_end_date Time.parse(@prompt.ask('Enter an end date (Y/M/D):')) end
ask_start_date()
click to toggle source
# File lib/utils/date/date.rb, line 16 def ask_start_date Time.parse(@prompt.ask('Enter a start date (Y/M/D):')) end
seconds_to_str(seconds)
click to toggle source
# File lib/utils/date/date.rb, line 24 def seconds_to_str(seconds) ["#{seconds / 3600}h", "#{seconds / 60 % 60}m", "#{seconds % 60}s"] .select { |str| str =~ /[1-9]/ }.join(' ') end