;; This file: http://user.it.uu.se/~embe8573/conf/emacs-init/time-my.el (require 'linux-shell) (defun time-between-times (year1 month1 day1 year2 month2 day2) (let*((seconds-then (float-time (encode-time 0 0 0 day1 month1 year1))) (seconds-now (float-time (encode-time 0 0 0 day2 month2 year2))) (seconds-diff (- seconds-now seconds-then)) ) (format-seconds "%Y, %D" seconds-diff))) (defun get-time-since (year month day) (interactive "nyear: \nnmonth: \nnday: ") (message "%s" (format-seconds "%Y, %D" (float-time (time-since (encode-time 0 0 0 day month year)) )))) ;; test: ;; (time-between-times 1996 5 11 2002 9 30) ;; (time-between-times 2008 10 17 2015 5 6) ;; (time-between-times 2010 4 15 2015 3 16) ;; (insert "\n;; " (get-time-since 2013 12 1)) ;; 2 years, 92 days (defun message-shell-command-output (command) (interactive "s$ ") (with-temp-buffer (shell-command command 1) (message (buffer-substring (point-min) (1- (point-max)))) )) ;; `show-time-and-date' relies on the zsh function long-date in (defun show-time-and-date (&optional insert) (interactive "P") (let ((date-script "long-date")) (if insert (insert-shell-command date-script) (message-shell-command-output date-script) ))) (defalias 'd 'show-time-and-date) (provide 'time-my)