diff options
Diffstat (limited to 'src/utils')
-rw-r--r-- | src/utils/utils.cr | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/utils/utils.cr b/src/utils/utils.cr new file mode 100644 index 0000000..7b214ce --- /dev/null +++ b/src/utils/utils.cr @@ -0,0 +1,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
\ No newline at end of file |