unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Ulrich Mueller <ulm@gentoo.org>, Paul Eggert <eggert@cs.ucla.edu>
Cc: 72570@debbugs.gnu.org
Subject: bug#72570: 31.0.50; Regression in date-to-time
Date: Mon, 12 Aug 2024 14:42:07 +0300	[thread overview]
Message-ID: <86zfpige7k.fsf@gnu.org> (raw)
In-Reply-To: <uplqf8mi2@gentoo.org> (message from Ulrich Mueller on Sun, 11 Aug 2024 10:57:57 +0200)

> From: Ulrich Mueller <ulm@gentoo.org>
> Date: Sun, 11 Aug 2024 10:57:57 +0200
> 
> Function documentation of 'date-to-time' says:
> "If DATE lacks timezone information, GMT is assumed."
> 
> Also, the Lispref Manual:
> "This function assumes Universal Time if STRING lacks explicit time zone
> information, ..."
> 
>   (format-time-string
>    "%Y-%m-%d %H:%M:%S" (date-to-time "2024-01-01 00:00:00") t)
> 
> returns "2023-12-31 23:00:00" as its result, while I would expect
> "2024-01-01 00:00:00" with both conversions being in the same (UTC)
> timezone. Apparently, date-to-time incorrectly uses the local timezone
> (Europe/Berlin) instead of UTC.
> 
> In Emacs 23.4 the function worked as expected.
> 
> Git bisecting points to this commit:
> 
>   commit b069e5a697f37a06704136a8d5376b4d088658c8 (HEAD)
>   Author: Gnus developers <ding@gnus.org>
>   Date:   Thu Sep 23 00:30:37 2010 +0000
> 
>       Merge Changes made in Gnus trunk.
> 
>       [...]
>       time-date.el (date-to-time): Speed up date-to-time.
>       [...]

That commit made this change in date-to-time:

  -      (apply 'encode-time
  -            (parse-time-string
  -             ;; `parse-time-string' isn't sufficiently general or
  -             ;; robust.  It fails to grok some of the formats that
  -             ;; timezone does (e.g. dodgy post-2000 stuff from some
  -             ;; Elms) and either fails or returns bogus values.  Lars
  -             ;; reverted this change, but that loses non-trivially
  -             ;; often for me.  -- fx
  -             (timezone-make-date-arpa-standard date)))
  -    (error (error "Invalid date: %s" date))))
  +      (apply 'encode-time (parse-time-string date))
  +    (error (condition-case ()
  +              (apply 'encode-time
  +                     (parse-time-string
  +                      (timezone-make-date-arpa-standard date)))
  +            (error (error "Invalid date: %s" date))))))

IOW, it applied parse-time-string to the argument DATE instead of
first running it through timezone-make-date-arpa-standard.

But that is not necessarily incorrect, because several time-conversion
functions, including those involved in this issue, don't document
their assumptions about time-zone when it is omitted.  This includes
parse-time-string and iso8601-parse.  Since these functions don't
document this aspect, and the code involved in the above snippet is
quite convoluted, it is hard for me to decide which part of what
function needs to be fixed.

Paul, any suggestions?  And can we please document the missing
time-zone assumptions?





  parent reply	other threads:[~2024-08-12 11:42 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-11  8:57 bug#72570: 31.0.50; Regression in date-to-time Ulrich Mueller
2024-08-12  7:27 ` Ulrich Mueller
2024-08-12  8:18   ` Ulrich Mueller
2024-08-12 11:42 ` Eli Zaretskii [this message]
2024-08-12 12:51   ` Ulrich Mueller
2024-08-12 13:26     ` Eli Zaretskii
2024-08-12 13:48       ` Ulrich Mueller
2024-08-12 14:30         ` Eli Zaretskii
2024-08-12 22:03   ` Paul Eggert
2024-08-13  5:55     ` Ulrich Mueller
2024-08-13 19:39       ` Paul Eggert
2024-08-13 21:11         ` Ulrich Mueller
2024-08-13 21:19           ` Paul Eggert
2024-08-14  8:12             ` Ulrich Mueller
2024-08-14 14:09             ` Ulrich Mueller
2024-08-15  3:27               ` Paul Eggert
2024-08-15  4:35                 ` Ulrich Mueller
2024-08-15  6:26                   ` Paul Eggert
2024-08-15  6:45                   ` Eli Zaretskii
2024-08-15  7:18                     ` Ulrich Mueller
2024-08-15  7:22                       ` Eli Zaretskii
2024-08-13 11:15     ` Eli Zaretskii
2024-08-13 15:09       ` Ulrich Mueller
2024-08-13 15:36         ` Eli Zaretskii
2024-08-13 19:59       ` Paul Eggert
2024-08-14  8:37         ` Eli Zaretskii

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=86zfpige7k.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=72570@debbugs.gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=ulm@gentoo.org \
    /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).