help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

even elder races get tired of waiting


From: Emanuel Berg
Subject: even elder races get tired of waiting
Date: Sat, 20 Mar 2021 21:37:59 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

;;; this file:
;;;   http://user.it.uu.se/~embe8573/emacs-init/time-cmp.el
;;;   https://dataswamp.org/~incal/emacs-init/time-cmp.el

;; ...

(require 'cl-lib)
(defun days-from-date (d1 d2)
  (let*((sep     "-")
        (d1-data (cl-map 'list #'string-to-number (split-string d1 sep)))
        (d2-data (cl-map 'list #'string-to-number (split-string d2 sep)))
        (y1      (car   d1-data))
        (m1      (cadr  d1-data))
        (d1      (caddr d1-data))
        (y2      (car   d2-data))
        (m2      (cadr  d2-data))
        (d2      (caddr d2-data)) )
    (days-from y1 m1 d1 y2 m2 d2) ))
;; (days-from-date "2021-03-19" "2021-04-20") ; 31

(defun days-from (y1 m1 d1 y2 m2 d2)
  (let*((s-then (float-time (encode-time 0 0 0 d1 m1 y1)))
        (s-now  (float-time (encode-time 0 0 0 d2 m2 y2)))
        (s-diff (- s-now s-then)) )
    (string-to-number (format-seconds "%d" s-diff) )))
;; (days-from 2021 03 19 2021 04 20) ; 31

-- 
underground experts united
http://user.it.uu.se/~embe8573
https://dataswamp.org/~incal




reply via email to

[Prev in Thread] Current Thread [Next in Thread]