Make epoch time function more useful

This commit is contained in:
Jeremy Dormitzer 2022-10-05 11:54:07 -04:00
parent 5f94f08c32
commit 7dad64f80f

View File

@ -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)