Class: Utils::DateUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/bujo/utils/dates.rb

Class Method Summary collapse

Class Method Details

.computer_readable_date(date = Date.today) ⇒ Object



17
18
19
# File 'lib/bujo/utils/dates.rb', line 17

def self.computer_readable_date(date = Date.today)
  date.strftime("%Y-%m-%d")
end

.computer_readable_month(date = Date.today) ⇒ Object



21
22
23
# File 'lib/bujo/utils/dates.rb', line 21

def self.computer_readable_month(date = Date.today)
  date.strftime("%Y-%m")
end

.day(date = Date.today) ⇒ Object



5
6
7
# File 'lib/bujo/utils/dates.rb', line 5

def self.day(date = Date.today)
  date.strftime("%d")
end

.human_readable_date(date = Date.today) ⇒ Object



9
10
11
# File 'lib/bujo/utils/dates.rb', line 9

def self.human_readable_date(date = Date.today)
  date.strftime("%d/%m/%Y")
end

.human_readable_month(date = Date.today) ⇒ Object



13
14
15
# File 'lib/bujo/utils/dates.rb', line 13

def self.human_readable_month(date = Date.today)
  date.strftime("%m/%Y")
end

.parse_human_readable_date(date_as_string) ⇒ Object



25
26
27
# File 'lib/bujo/utils/dates.rb', line 25

def self.parse_human_readable_date(date_as_string)
  Date.strptime(date_as_string, "%d/%m/%Y")
end

.parse_human_readable_month(month_as_string) ⇒ Object



29
30
31
# File 'lib/bujo/utils/dates.rb', line 29

def self.parse_human_readable_month(month_as_string)
  Date.strptime("01/#{month_as_string}", "%d/%m/%Y")
end