summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2023-07-25 04:38:14 +0100
committerjao <jao@gnu.org>2023-07-25 04:38:14 +0100
commit36903f998f82f79c2aabdbaf666036a63e9b5e16 (patch)
treeb29f9172ae3db243b08e683d71ec10df7b6d7f5f
parentaf63540b8d9708c18df6712112964308f6e0182f (diff)
downloadelibs-36903f998f82f79c2aabdbaf666036a63e9b5e16.tar.gz
elibs-36903f998f82f79c2aabdbaf666036a63e9b5e16.tar.bz2
time-to-epoch and the other way round recovered
-rw-r--r--init.el16
1 files changed, 16 insertions, 0 deletions
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