From 8a9354f50f9626ce669adea85f9b92087beb531a Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Sun, 23 Oct 2022 18:24:08 +0100 Subject: [PATCH] implement create-timestamp-text function in utils package. This is a variation on the create-timestamp-id used for generating a timestamp-id for the Meilisearch database. This text-based timestamp takes the form of YYYY-MM-DD_HH-MM-SS. The main intention of this function is to use is as part of a directory name when generating a snapshot (of the website's data/DB). --- src/utils.lisp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/utils.lisp b/src/utils.lisp index 0e5d87f..d422055 100644 --- a/src/utils.lisp +++ b/src/utils.lisp @@ -6,10 +6,7 @@ #:xml-emitter #:app-constants #:storage) - (:export #:i18n-load - #:_ - #:parse-iso-date - #:request-params + (:export #:request-params #:string-is-nil-or-empty? #:separate-files-in-web-request #:set-alert @@ -27,7 +24,8 @@ #:build-alert-string #:month-number-to-name #:build-url-root - #:build-url) + #:build-url + #:create-timestamp-text) (:documentation "Utilities that do not depend on models.")) (in-package #:utils) @@ -171,6 +169,13 @@ to operate properly." (get-decoded-time) (format nil "~d~2,'0d~d~2,'0d~2,'0d~2,'0d" year month day hour minute second))) +(defun create-timestamp-text () + "Creates a text-based timestamp (value being the time function was called)." + (multiple-value-bind + (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")