diff options
author | jao <jao@gnu.org> | 2023-07-25 04:38:14 +0100 |
---|---|---|
committer | jao <jao@gnu.org> | 2023-07-25 04:38:14 +0100 |
commit | 36903f998f82f79c2aabdbaf666036a63e9b5e16 (patch) | |
tree | b29f9172ae3db243b08e683d71ec10df7b6d7f5f | |
parent | af63540b8d9708c18df6712112964308f6e0182f (diff) | |
download | elibs-36903f998f82f79c2aabdbaf666036a63e9b5e16.tar.gz elibs-36903f998f82f79c2aabdbaf666036a63e9b5e16.tar.bz2 |
time-to-epoch and the other way round recovered
-rw-r--r-- | init.el | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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 |