Class: Timert::DateUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/timert/date_util.rb

Class Method Summary collapse

Class Method Details

.format_date(date) ⇒ Object



10
11
12
# File 'lib/timert/date_util.rb', line 10

def self.format_date(date)
  date ? date.strftime("%Y-%m-%d") : ""
end

.format_hour(timestamp) ⇒ Object



6
7
8
# File 'lib/timert/date_util.rb', line 6

def self.format_hour(timestamp)
  timestamp ? Time.at(timestamp).strftime("%H:%M:%S") : ""
end

.format_month(date) ⇒ Object



14
15
16
# File 'lib/timert/date_util.rb', line 14

def self.format_month(date)
  date ? date.strftime("%Y-%m") : ""
end

.parse_time(arg) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/timert/date_util.rb', line 18

def self.parse_time(arg)
  if arg
    hours, minutes = arg.split(":")
    now = Time.now
    Time.new(now.year, now.month, now.day, hours, minutes).to_i
  end
end