Browse Source

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).
stable
Craig Oates 2 years ago
parent
commit
8a9354f50f
  1. 15
      src/utils.lisp

15
src/utils.lisp

@ -6,10 +6,7 @@
#:xml-emitter #:xml-emitter
#:app-constants #:app-constants
#:storage) #:storage)
(:export #:i18n-load (:export #:request-params
#:_
#:parse-iso-date
#:request-params
#:string-is-nil-or-empty? #:string-is-nil-or-empty?
#:separate-files-in-web-request #:separate-files-in-web-request
#:set-alert #:set-alert
@ -27,7 +24,8 @@
#:build-alert-string #:build-alert-string
#:month-number-to-name #:month-number-to-name
#:build-url-root #:build-url-root
#:build-url) #:build-url
#:create-timestamp-text)
(:documentation "Utilities that do not depend on models.")) (:documentation "Utilities that do not depend on models."))
(in-package #:utils) (in-package #:utils)
@ -171,6 +169,13 @@ to operate properly."
(get-decoded-time) (get-decoded-time)
(format nil "~d~2,'0d~d~2,'0d~2,'0d~2,'0d" year month day hour minute second))) (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) (defun month-number-to-name (month-number)
"Converts `MONTHS-NUMBER' to its name (E.G. 1 to 'January')." "Converts `MONTHS-NUMBER' to its name (E.G. 1 to 'January')."
(cond ((= 1 month-number) "January") (cond ((= 1 month-number) "January")

Loading…
Cancel
Save