From 36903f998f82f79c2aabdbaf666036a63e9b5e16 Mon Sep 17 00:00:00 2001 From: jao Date: Tue, 25 Jul 2023 04:38:14 +0100 Subject: time-to-epoch and the other way round recovered --- init.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/init.el b/init.el index 0d1fecf..1c1405a 100644 --- a/init.el +++ b/init.el @@ -485,6 +485,22 @@ display-time-default-load-average nil display-time-format " %a %e %H:%M") +(defun jao-time-to-epoch (&optional s) + "Transform a time string to an epoch integer in milliseconds." + (interactive) + (let ((s (or s (read-string "Time string: " (thing-at-point 'string))))) + (message "%s = %s" + s + (round (* 1000 (time-to-seconds (parse-time-string s))))))) + +(defun jao-epoch-to-time (&optional v) + "Transform an epoch, given in milliseconds, to a time string." + (interactive) + (let ((v (or v (read-number "Milliseconds: " (thing-at-point 'number))))) + (message "%s = %s" v + (format-time-string "%Y-%m-%d %H:%M:%S" + (seconds-to-time (/ v 1000.0)))))) + ;;;; mode line toggle (use-package jao-mode-line :init -- cgit v1.2.3