aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorIndrajith K L2024-06-22 03:40:56 +0530
committerIndrajith K L2024-06-22 03:40:56 +0530
commit646fdccac5f0ec506b80ed532baa4012965b682e (patch)
treeced54009d8d5f20b61d7a873a6bb54907e8b7e5d /src/utils
parenta5b35ffb182e4b2aa250059b0e44c13373999d76 (diff)
downloadindrajith-dev-crystal-646fdccac5f0ec506b80ed532baa4012965b682e.tar.gz
indrajith-dev-crystal-646fdccac5f0ec506b80ed532baa4012965b682e.tar.bz2
indrajith-dev-crystal-646fdccac5f0ec506b80ed532baa4012965b682e.zip
Date Utils, Cosmetic and Implementation Changes
* Adds Utils method for formatting date * Adds Published at to the posts page * Adds new logo, removes font dependency * Renames Posts link to Blog
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/utils.cr47
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