From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jean Louis Newsgroups: gmane.emacs.help Subject: Re: even elder races get tired of waiting Date: Mon, 22 Mar 2021 10:48:11 +0300 Message-ID: References: <87v99lr26w.fsf@zoho.eu> <8735woph4e.fsf@zoho.eu> <87h7l4nnqs.fsf@zoho.eu> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15601"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/2.0.6 (2021-03-06) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 22 08:57:09 2021 Return-path: Envelope-to: geh-help-gnu-emacs@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 1lOFQz-0003wQ-GC for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 22 Mar 2021 08:57:09 +0100 Original-Received: from localhost ([::1]:42154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lOFQx-0002C2-RL for geh-help-gnu-emacs@m.gmane-mx.org; Mon, 22 Mar 2021 03:57:07 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:50626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOFNJ-0000C7-M6 for help-gnu-emacs@gnu.org; Mon, 22 Mar 2021 03:53:22 -0400 Original-Received: from stw1.rcdrun.com ([217.170.207.13]:38659) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lOFNF-0000Vi-7k for help-gnu-emacs@gnu.org; Mon, 22 Mar 2021 03:53:21 -0400 Original-Received: from localhost ([::ffff:41.202.241.53]) (AUTH: PLAIN securesender, TLS: TLS1.3,256bits,ECDHE_RSA_AES_256_GCM_SHA384) by stw1.rcdrun.com with ESMTPSA id 000000000001E0AB.0000000060584CEA.00003AC5; Mon, 22 Mar 2021 00:53:14 -0700 Mail-Followup-To: help-gnu-emacs@gnu.org Content-Disposition: inline In-Reply-To: <87h7l4nnqs.fsf@zoho.eu> Received-SPF: pass client-ip=217.170.207.13; envelope-from=bugs@gnu.support; helo=stw1.rcdrun.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128497 Archived-At: * Emanuel Berg via Users list for the GNU Emacs text editor [2021-03-22 01:31]: > >> OK? And days start at 00:00? > > > > Good question! > > > > There are few definitions for days, some definitions will > > say it starts at zero, some others will tell it is interval > > of 24 hours, not necessarily starting at zero, and some > > definition will speak of daylight period. [...] > > How do you suggest I improve the function? Maybe you should first define what is meant with `days-from-date'. I like that type of functions and I was looking for that in pure Emacs lisp, and found the same what you already implemented that it could be possible to calculate with dates and get differences. Yet I am still sticking to external PostgreSQL based solutions. Your function brought me to thinking and I am still confused if I was calculating well the periods of time from one to other date, but no human so far complained, that is why I said that human error makes the functions work any way. If you wish to say that `days-from-date' is calculated purely mathematically, then what is the meaning of "from date", does it include the date or it starts after the date? We have seen how humans calculate "from date" often by including the date, like in: In "We work from Monday to Friday" the expression "from" and "to" includes both the beginning day and the ending day. Because of so much ambiguity you would need to define what `days-from-date' is meant to represent. (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 Gives me 32 now. (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 Now the above gives me 32 in this moment March 22 10:40 EAT, how comes? It was giving me 31 before.