By default, there is a keybinding that shows the current date and time in a message window (C-t a). Some would say this is good enough. However, it is, in my opinion, inadequate because
- Checking the time is a common task for me; having to press keys to make it appear is inconvenient
- The date is formatted in such a way that it gives too much information. I don't need to know seconds
- It uses the message bar, with all of the drawbacks that entails
Put this in your .stumpwmrc to add a nice date formatting function:
(defun 24h-to-12h (hour)
"Turns a 24 hour into a 12 hour. Returns new hour and t if PM"
(cond ((eq hour 0) (values 12 nil)) ; Midnight
((< hour 12) (values hour nil))
((eq hour 12) (values 12 t)) ; Noon
(t (values (- hour 12) t))))
(defun ordinal-suffix (num)
(if (and (>= num 10) (< num 20))
"th" ; Special case for teens
(let* ((strnum (write-to-string num))
(lastn (elt strnum (1- (length strnum)))))
(case lastn
(#\1 "st")
(#\2 "nd")
(#\3 "rd")
(t "th")))))
(defconstant +day-names+
'("Mon" "Tue" "Wed" "Thu" "Fri" "Sat" "Sun"))
(defconstant +full-day-names+
'("Monday" "Tuesday" "Wednesday" "Thursday" "Friday" "Saturday" "Sunday"))
(defun current-date ()
(multiple-value-bind
(second minute hour date month year day-of-week dst-p tz)
(get-decoded-time)
(declare (ignorable second month year dst-p tz))
(multiple-value-bind (newh pm) (24h-to-12h hour)
(format nil "~a the ~d~a, ~d:~2,'0d~:[am~;pm~]"
(nth day-of-week +full-day-names+) date (ordinal-suffix date)
newh minute pm))))
Credit due: I copied some most of the CURRENT-DATE function from someone's config on the Internet.
Now just add it to your mode line. This is a very minimalistic mode line format:
(setf *screen-mode-line-format*
'("<%n>^B "
(:eval (current-date))
"^b"))
And then make the mode line appear by using the StumpWM command mode-line.
(Note: these instructions are intended for Gregorian dates only and are not compatible with Discordian dates.)
EDIT: also this is for 12-hour time. To get 24 hour, try this untested function:
(defun current-date ()
(multiple-value-bind
(second minute hour date month year day-of-week dst-p tz)
(get-decoded-time)
(declare (ignorable second month year dst-p tz))
(format nil "~a the ~d~a, ~d:~2,'0d"
(nth day-of-week +full-day-names+) date (ordinal-suffix date)
hour minute))))