From 6389480260cb8e740756b5fd2c1fa81435550836 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Mon, 10 Oct 2022 16:27:47 +0100 Subject: [PATCH] create month-number-to-name function in utils package. This is a helper function to convert '1' to 'January', for example. The intended use for this is to work alongside the local-time package when generating the month number from a timestamp. --- src/utils.lisp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/utils.lisp b/src/utils.lisp index da5c523..a5565e9 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -23,7 +23,8 @@ #:create-timestamp-id #:format-filename #:format-keywords - #:build-alert-string) + #:build-alert-string + #:month-number-to-name) (:documentation "Utilities that do not depend on models.")) (in-package #:utils) @@ -166,3 +167,19 @@ to operate properly." (second minute hour day month year) (get-decoded-time) (format nil "~d~2,'0d~d~2,'0d~2,'0d~2,'0d" year month day hour minute second))) + +(defun month-number-to-name (month-number) + "Converts `MONTHS-NUMBER' to its name (E.G. 1 to 'January')." + (cond ((= 1 month-number) "January") + ((= 2 month-number) "February") + ((= 3 month-number) "March") + ((= 4 month-number) "April") + ((= 5 month-number) "May") + ((= 6 month-number) "June") + ((= 7 month-number) "July") + ((= 8 month-number) "August") + ((= 9 month-number) "September") + ((= 10 month-number) "October") + ((= 11 month-number) "November") + ((= 12 month-number) "December") + (t nil)))