unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: Eli Zaretskii <eliz@gnu.org>
Cc: larsi@gnus.org, 48298@debbugs.gnu.org, lewwadoo@gmail.com
Subject: bug#48298: Invalid time specification: encode-time((0 30 11 1 1 0 nil -1 nil))
Date: Sun, 09 May 2021 09:54:32 +0100	[thread overview]
Message-ID: <87tunc4793.fsf@tcd.ie> (raw)
In-Reply-To: <83fsyw8g7f.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 09 May 2021 11:27:32 +0300")

[-- Attachment #1: Type: text/plain, Size: 581 bytes --]

Eli Zaretskii <eliz@gnu.org> writes:

>> From: "Basil L. Contovounesios" <contovob@tcd.ie>
>> Cc: Евгений Михайлов
>>  <lewwadoo@gmail.com>,  48298@debbugs.gnu.org
>> Date: Sun, 09 May 2021 09:19:47 +0100
>> 
>> > I guess the problem is in decoded-time-set-defaults, if anywhere.
>> 
>> Lars?
>
> As the minimum fix, perhaps instead of using zero as the missing year
> we should use 1970, as zero could not be representable on some
> systems.

Also 1970 is implied by the function's docstring and announcement.

All tests seem to pass with this:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Default-to-1970-in-decoded-time-set-defaults.patch --]
[-- Type: text/x-diff, Size: 1060 bytes --]

From 3bb0de4f76265d3be28c0b38046f1a08d93259b9 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Sun, 9 May 2021 09:50:00 +0100
Subject: [PATCH] Default to 1970 in decoded-time-set-defaults

* lisp/calendar/time-date.el (decoded-time-set-defaults): Set an
unspecified year field to 1970, as promised in the docstring, and to
ensure it's representable on all systems (bug#48298).
---
 lisp/calendar/time-date.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/calendar/time-date.el b/lisp/calendar/time-date.el
index 2df57a3c33..e93a74810d 100644
--- a/lisp/calendar/time-date.el
+++ b/lisp/calendar/time-date.el
@@ -539,7 +539,7 @@ decoded-time-set-defaults
   (unless (decoded-time-month time)
     (setf (decoded-time-month time) 1))
   (unless (decoded-time-year time)
-    (setf (decoded-time-year time) 0))
+    (setf (decoded-time-year time) 1970))
 
   ;; When we don't have a time zone, default to DEFAULT-ZONE without
   ;; DST if DEFAULT-ZONE if given, and to unknown DST otherwise.
-- 
2.30.2


[-- Attachment #3: Type: text/plain, Size: 764 bytes --]


Evgeny, does that fix the error that you see?

>> BTW I just noticed that decoded-time-set-defaults was mistakenly
>> announced in NEWS as encoded-time-set-defaults - should that be fixed on
>> emacs-27 or master?
>
> Master, I guess.

Done in 3d276324ed.

>> > However, I'm not sure I understand the idea behind your
>> > my-mins-between: how did you expect Emacs to guess the year you had in
>> > mind?
>> 
>> The year doesn't matter, since my-mins-between cares only about the
>> relative difference between strings of the form "HH:mm", i.e. the hours
>> and minutes fields.
>
> Yes, it does matter: see the comment by Andreas.

In general, sure, but perhaps not in Evgeny's specific use case as
described in https://bugs.gnu.org/48290#11.

Thanks,

-- 
Basil

  reply	other threads:[~2021-05-09  8:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-08 16:55 bug#48298: Invalid time specification: encode-time((0 30 11 1 1 0 nil -1 nil)) Евгений Михайлов
2021-05-08 22:37 ` Basil L. Contovounesios
2021-05-09  7:07   ` Eli Zaretskii
2021-05-09  6:46 ` Eli Zaretskii
2021-05-09  8:19   ` Basil L. Contovounesios
2021-05-09  8:27     ` Eli Zaretskii
2021-05-09  8:54       ` Basil L. Contovounesios [this message]
2021-05-09  9:52         ` Lars Ingebrigtsen
2021-05-09 10:03           ` Basil L. Contovounesios
2021-05-09 10:09             ` Lars Ingebrigtsen
2021-05-09 11:02               ` Basil L. Contovounesios
2021-05-09 10:35         ` Eli Zaretskii
2021-05-09 10:59           ` Basil L. Contovounesios
2021-05-09 11:49             ` Eli Zaretskii
2021-05-09 13:57               ` Basil L. Contovounesios
2021-05-09  7:30 ` Andreas Schwab
2021-05-11 20:56 ` bug#48298: Евгений Михайлов
2021-05-11 21:37   ` bug#48298: Basil L. Contovounesios

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tunc4793.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=48298@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=larsi@gnus.org \
    --cc=lewwadoo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).