From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg Newsgroups: gmane.emacs.tangents Subject: Re: 2022-11-14 Emacs news Date: Tue, 15 Nov 2022 05:39:28 +0100 Message-ID: <87o7t8q1a7.fsf@dataswamp.org> References: <875yfhfrs2.fsf@sachachua.com> <87bkp92h6m.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32395"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-tangents@gnu.org Cancel-Lock: sha1:6RCCP8SLAHpMDIoCbLAy2iNi0hg= Original-X-From: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Tue Nov 15 06:04:21 2022 Return-path: Envelope-to: get-emacs-tangents@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ouo7Q-0008DS-FK for get-emacs-tangents@m.gmane-mx.org; Tue, 15 Nov 2022 06:04:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ouo75-00050d-Gl; Tue, 15 Nov 2022 00:03:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ounja-0007uo-TA for emacs-tangents@gnu.org; Mon, 14 Nov 2022 23:39:42 -0500 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ounjZ-00083l-1o for emacs-tangents@gnu.org; Mon, 14 Nov 2022 23:39:42 -0500 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1ounjW-0007xb-7X for emacs-tangents@gnu.org; Tue, 15 Nov 2022 05:39:38 +0100 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: emacs-tangents@gnu.org Mail-Copies-To: never Received-SPF: pass client-ip=116.202.254.214; envelope-from=get-emacs-tangents@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Tue, 15 Nov 2022 00:03:56 -0500 X-BeenThere: emacs-tangents@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Emacs news and miscellaneous discussions outside the scope of other Emacs mailing lists List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Original-Sender: emacs-tangents-bounces+get-emacs-tangents=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.tangents:951 Archived-At: Sacha Chua wrote: > Maybe next week, we'll see! I think it should happen today, now even. It's about time. ;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/today.el (defun eat-and-beat (re data) (save-excursion (if (looking-at re) (replace-match data) (insert data) ) (save-buffer) )) (defun today () (interactive) (let ((date-re "[[:digit:]]\\{4\\}-[[:digit:]]\\{2\\}-[[:digit:]]\\{2\\}") (date (format-time-string "%F")) ) (eat-and-beat date-re date) )) (defun now () (interactive) (let ((time-re "[[:digit:]]\\{2\\}:[[:digit:]]\\{2\\}") (time (format-time-string "%R")) ) (eat-and-beat time-re time) )) (provide 'today) ;;; -*- lexical-binding: t -*- ;; ;; this file: ;; https://dataswamp.org/~incal/emacs-init/time-cmp.el (require 'cl-lib) (defun wall-clock-time (h1 m1 s1 h2 m2 s2) (let*((y 1978) (m 05) (d 08) ; arbitrary date, 1978-05-08 (total-seconds-1 (float-time (encode-time s1 m1 h1 d m y))) (total-seconds-2 (float-time (encode-time s2 m2 h2 d m y))) (s-diff (- total-seconds-2 total-seconds-1)) ) (format-seconds "%.2h:%.2m:%.2s" s-diff) )) (defalias 'wct #'wall-clock-time) ;; (wct 09 35 10 23 00 00) ; 13:24:50 (defun days (y1 m1 d1 y2 m2 d2) (let*((then (float-time (encode-time 0 0 0 d1 m1 y1))) (now (float-time (encode-time 0 0 0 d2 m2 y2))) (diff (- now then)) ) (string-to-number (format-seconds "%d" diff) ))) ;; (days 1958 04 13 1958 08 30) ; 139 days between Tahiti Nui 2 & 3 (defun days-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 y1 m1 d1 y2 m2 d2) )) ;; (days-date "2021-03-19" "2021-04-20") ; 31 ;; (days-date "1964-07-26" "2021-03-22") ; 20 693 (defun get-time-since (y m d) (interactive "nyear: \nnmonth: \nnday: ") (message "%s" (format-seconds "%yy %dd" (float-time (time-since (encode-time 0 0 0 d m y)) )))) ;; (get-time-since 2011 09 27) ; 10y 172d [2022-03-15] (defun days-since (y m d) (string-to-number (format-seconds "%d" (float-time (time-since (encode-time 0 0 0 d m y))) ))) ;; (days-since 1 1 1) ; 738 228 days from 0001-01-01 [2022-03-15] -- underground experts united https://dataswamp.org/~incal