From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: John Mastro Newsgroups: gmane.emacs.help Subject: Re: Question about parse-time-string and date-to-time Date: Wed, 29 Mar 2017 15:14:18 -0700 Message-ID: References: <87shlv23xt.fsf@ericabrahamsen.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: blaine.gmane.org 1490825710 26952 195.159.176.226 (29 Mar 2017 22:15:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 29 Mar 2017 22:15:10 +0000 (UTC) Cc: Eric Abrahamsen To: "help-gnu-emacs@gnu.org" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Mar 30 00:15:06 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctLrp-0006AF-61 for geh-help-gnu-emacs@m.gmane.org; Thu, 30 Mar 2017 00:15:01 +0200 Original-Received: from localhost ([::1]:32906 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctLru-0003xJ-Ue for geh-help-gnu-emacs@m.gmane.org; Wed, 29 Mar 2017 18:15:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39124) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctLrU-0003xE-NU for help-gnu-emacs@gnu.org; Wed, 29 Mar 2017 18:14:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctLrT-0001mg-Pn for help-gnu-emacs@gnu.org; Wed, 29 Mar 2017 18:14:40 -0400 Original-Received: from mail-qk0-x230.google.com ([2607:f8b0:400d:c09::230]:34412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctLrT-0001lX-LV for help-gnu-emacs@gnu.org; Wed, 29 Mar 2017 18:14:39 -0400 Original-Received: by mail-qk0-x230.google.com with SMTP id d10so25798170qke.1 for ; Wed, 29 Mar 2017 15:14:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=/7MvQ6LVltzsqa5+pBW3L6DZoBBlXIhdKHiA5cRQQ7A=; b=FNPOxKZ2jzWMvO5iIs56pyWwJibKxwMhJPL9msTwHemZuXs1VvMsUvPvOLlhfoRS+m eyH28r7fPZP5QYSxTfpidujDtbAG9JggQ0nnGQggfiFNVNhT+Z1GMuc+qIi1Aq4/wwHy cJAMQfAW7ibnM6/dl4hTq06qTiYrgRD/ll4eshqksTric8XrffsyGphymPT6ZZlw65WT U0XVHhM0dCrpmjhRfpHzhqAKGwV3/3Tz6xmc525DRKGW4Y6tQsw/ikg+cLYdEGsr26Mu 6TL2yxTaNmA4tz/BF5zCMKe3rDe2sq1JBhDHPt3trDWs8VqyhevEVNGd/Zxu7FebVU/A +ZJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=/7MvQ6LVltzsqa5+pBW3L6DZoBBlXIhdKHiA5cRQQ7A=; b=QfnXvpPBR8mHboun8973ZfImdnqS+A7kgz6oQ7RbK3lteUmSBcSPCNzzWL+6GJM69S Vy4VfwS5XmAEJB7TWd4TxcG9kgZ/zQNLxYj/B/HZH/XSMIfNPJ8mixgVK1oFJqbqutC4 tEdwHMSU9ncUT83erzRoA/C4VsKLj3MU7qgs2EppPrHM85Jz/inEy60wXWSnOcPdaABp RdvNqAKvZoUAcKnaebkSKLxp9cp6Cq5GlSgKS8WeghZ17sJhQs1yn4g4qkt38yZep+bg rc8rfpaGSptAPV4s2UdtjUCziNK0ER9EJDCKgg5WFGEglfWuVvmmNDnxXUz4mfoe9FlO 0hgg== X-Gm-Message-State: AFeK/H3VmbKer5et+2lh1jTm5HhSBkpekZTqMXZkTgIzdC76co+6FvidFiNNFCIaQWNHsjEwRrenm+r/A8glTA== X-Received: by 10.233.237.135 with SMTP id c129mr3086141qkg.160.1490825678680; Wed, 29 Mar 2017 15:14:38 -0700 (PDT) Original-Received: by 10.237.49.162 with HTTP; Wed, 29 Mar 2017 15:14:18 -0700 (PDT) In-Reply-To: <87shlv23xt.fsf@ericabrahamsen.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::230 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 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.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:112666 Archived-At: Eric Abrahamsen wrote: > A conundrum: > > parse-time-string accepts a string representing a date, and parses it > into a list of time elements, with nil for the unknowns. > > date-to-time calls parse-time-string and passes the result straight to > encode-time, to produce a time value. > > encode-time accepts series of time elements, and raises an error if any > of them are nil. > > I might be missing something, but I don't see how date-to-time could > ever work. Wouldn't it always have to replace the nils with zeros before > passing the result to encode time? It looks like, if the first call to `encode-time' signals an error, it re-tries using the result of calling `timezone-make-date-arpa-standard' on the original DATE argument: (defun date-to-time (date) (condition-case err (apply 'encode-time (parse-time-string date)) (error ;; ... (apply 'encode-time (parse-time-string (timezone-make-date-arpa-standard date))) ;; ... ))) I was not familiar with `timezone-make-date-arpa-standard', and am not familiar with "arpanet standard date" as a concept. It seems to guarantee that some valid date string will be returned, but not necessarily the one I would have guessed when time information is missing: (timezone-make-date-arpa-standard "2017-03-29 3:05:00") ;=> "28 Mar 2017 20:05:00 -0700" (timezone-make-date-arpa-standard "2017-03-29") ;=> "31 Dec 1999 16:00:00 -0800" (timezone-make-date-arpa-standard "3/29/2016") ;=> "31 Dec 1999 16:00:00 -0800" And sure enough: (equal (date-to-time "2017-03-29") (date-to-time "31 Dec 1999 16:00:00 -0800")) ;=> t So it seems like it returns an arbitrary date if time elements are missing? John