aboutsummaryrefslogtreecommitdiff
path: root/.config/luastatus-scripts-dwm/time-date.lua
diff options
context:
space:
mode:
Diffstat (limited to '.config/luastatus-scripts-dwm/time-date.lua')
-rw-r--r--.config/luastatus-scripts-dwm/time-date.lua58
1 files changed, 58 insertions, 0 deletions
diff --git a/.config/luastatus-scripts-dwm/time-date.lua b/.config/luastatus-scripts-dwm/time-date.lua
new file mode 100644
index 0000000..8fce7a1
--- /dev/null
+++ b/.config/luastatus-scripts-dwm/time-date.lua
@@ -0,0 +1,58 @@
+months = {'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'}
+wday = {'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'}
+widget = {
+ plugin = 'timer',
+ cb = function()
+ local d = os.date('*t')
+
+ if d.hour < 12 then
+ suffix = "a.m."
+ else
+ suffix = "p.m."
+ d.hour = d.hour - 12
+ end
+
+ local date_suffix = "th"
+ if not (d.day % 100 >= 11 and d.day % 100 <= 13) then
+ local last_digit = d.day % 10
+ if last_digit == 1 then
+ date_suffix = "st"
+ elseif last_digit == 2 then
+ date_suffix = "nd"
+ elseif last_digit == 3 then
+ date_suffix = "rd"
+ end
+ end
+
+ local time_icon = ""
+ if d.hour == 0 or d.hour == 12 then
+ time_icon = "󱑖"
+ elseif d.hour == 1 then
+ time_icon = "󱑋"
+ elseif d.hour == 2 then
+ time_icon = "󱑌"
+ elseif d.hour == 3 then
+ time_icon = "󱑍"
+ elseif d.hour == 4 then
+ time_icon = "󱑎"
+ elseif d.hour == 5 then
+ time_icon = "󱑏"
+ elseif d.hour == 6 then
+ time_icon = "󱑐"
+ elseif d.hour == 7 then
+ time_icon = "󱑑"
+ elseif d.hour == 8 then
+ time_icon = "󱑒"
+ elseif d.hour == 9 then
+ time_icon = "󱑓"
+ elseif d.hour == 10 then
+ time_icon = "󱑔"
+ elseif d.hour == 11 then
+ time_icon = "󱑕"
+ end
+
+ return {
+ string.format('󰃭 %d%s %s %d (%s) %s %d:%02d %s ', d.day, date_suffix, months[d.month], d.year, wday[d.wday], time_icon, d.hour, d.min, suffix),
+ }
+ end,
+}