From 7dad64f80f90994ba9891eeced74e50ed67494ff Mon Sep 17 00:00:00 2001 From: Jeremy Dormitzer Date: Wed, 5 Oct 2022 11:54:07 -0400 Subject: [PATCH] Make epoch time function more useful --- emacs/.emacs.d/config/init-utils.el | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/emacs/.emacs.d/config/init-utils.el b/emacs/.emacs.d/config/init-utils.el index f22a453..964626c 100644 --- a/emacs/.emacs.d/config/init-utils.el +++ b/emacs/.emacs.d/config/init-utils.el @@ -1,8 +1,11 @@ ;; -*- lexical-binding: t; -*- (defun unix-time-to-string (epoch-seconds &optional format-string) "Converts an epoch timestamp into a human-readable string." - (interactive "sUnix timestamp: ") - (let ((format-string (or format-string "%FT%T%z"))) - (format-time-string format-string epoch-seconds))) + (interactive "nUnix timestamp: ") + (let* ((format-string (or format-string "%FT%T%z")) + (formatted (format-time-string format-string epoch-seconds))) + (if (called-interactively-p) + (message formatted) + formatted))) (provide 'init-utils)