aboutsummaryrefslogtreecommitdiff
path: root/src/utils/utils.cr
blob: 7b214ce88cf288b7f62133159fa7f15a8dcaaf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def format_date(time : Time)
    month = get_month(time.month)
    "#{month} #{time.day}, #{time.year}"
end

def format_date_with_time(time : Time)
    month = get_month(time.month)
    "#{month} #{time.day}, #{time.year} #{time.hour}:#{time.minute} #{am_or_pm(time.hour)}"
end

def get_month(month)
    case month
    when 1
        "January"
    when 2
        "February"
    when 3
        "March"
    when 4
        "April"
    when 5
        "May"
    when 6
        "June"
    when 7
        "July"
    when 8
        "August"
    when 9
        "September"
    when 10
        "October"
    when 11
        "November"
    when 12
        "December"
    end
end

def am_or_pm(hour)
    if hour > 12
        "PM"
    else
        "AM"
    end
end