emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ihor Radchenko <yantar92@gmail.com>
To: Max Nikulin <manikulin@gmail.com>
Cc: Paul Eggert <eggert@cs.ucla.edu>, org-mode-email <emacs-orgmode@gnu.org>
Subject: Re: [DRAFT][PATCH] org-encode-time compatibility and convenience helper
Date: Sat, 23 Apr 2022 16:25:00 +0800	[thread overview]
Message-ID: <87mtgcmckj.fsf@localhost> (raw)
In-Reply-To: <7f4ea652-7d22-fb61-f873-5e92f078c9e6@gmail.com>

Max Nikulin <manikulin@gmail.com> writes:

> I tried to create a compatibility helper that will use currently 
> recommended way to call `encode-time' with single list argument for 
> Emacs-27 and newer, but use the only available call style as separated 
> arguments for older Emacs versions.

Thanks for this work!

>  From my point of view
> - it should work at the compile or load time to minimize runtime 
> performance impact,
> - since both ways to call `encode-time' are necessary (in a half of 
> cases a list returned by `decode-time' is available, in other cases 
> timestamps are assembled from scratch, none is preferred), it should be 
> convenient in both cases,
> - it should allow Org to work even if support of multiple `encode-time' 
> arguments will be removed from Emacs.

Agree.

> My patch requires more changes since the macro is just defined but not 
> actually used. It does not fix the problem with "no DST" flag returned 
> by some function in Org. I can prepare next patches, but I think it 
> should be decided at first which approach should be accepted by Org Mode:
> - org-encode-time accepting both list or separate arguments
> - mix of `encode-time' with multiple arguments and org-encode-time-1 for 
> lists.

This whole timezone staff is complex. I got lost in the emacs devel
discussion half-way through. From point of view of API, I would prefer a
single function with docstring explaining the necessary caveats.

> +      (if (cdr time)
> +          `(encode-time ,@time)
> +        `(apply #'encode-time ,(car time))))

Do I miss something or can you instead just do `(encode-time ,@time)
without if?

> +  (should (string-equal
> +           "2022-03-24 23:30:01"
> +           (format-time-string
> +            "%F %T"
> +            (org-encode-time '(01 30 23 24 03 2022 nil -1 nil)))))
> ...

These tests will be executed using system value of TZ. I am not sure if
tests are not going to break, say, in southern hemisphere or at some
other bizzare values of TZ.

> +  ;; daylight saving time
> +  (let ((tz (getenv "TZ")))
> +    (unwind-protect
> +        (progn
> +          (setenv "TZ" "Europe/Madrid")
> +          (should (string-equal
> +                   "2022-03-31 23:30:06"
> +                   (format-time-string
> +                    "%F %T"
> +                    (org-encode-time 06 30 23 31 03 2022)))))
> +      (setenv "TZ" tz))))

Best,
Ihor


  parent reply	other threads:[~2022-04-23  8:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11 15:22 Max Nikulin
2022-04-11 17:43 ` Paul Eggert
2022-04-23  8:25 ` Ihor Radchenko [this message]
2022-04-23 19:37   ` Paul Eggert
2022-04-24  3:35     ` Ihor Radchenko
2022-04-24 11:34   ` [DRAFT][PATCH v2] " Max Nikulin
2022-04-26  9:07     ` Ihor Radchenko
2022-05-03 12:14       ` [PATCH v3] " Max Nikulin
2022-05-04  9:56         ` Ihor Radchenko
2022-05-04 16:49           ` Max Nikulin
2022-05-05 15:22           ` [PATCH v4] " Max Nikulin
2022-05-07  4:46             ` Ihor Radchenko
2022-05-10 14:31             ` Max Nikulin
2022-05-11 13:20               ` Ihor Radchenko
2022-05-13 15:14                 ` Max Nikulin
2022-05-14  6:06                   ` Ihor Radchenko

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.orgmode.org/

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

  git send-email \
    --in-reply-to=87mtgcmckj.fsf@localhost \
    --to=yantar92@gmail.com \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-orgmode@gnu.org \
    --cc=manikulin@gmail.com \
    --subject='Re: [DRAFT][PATCH] org-encode-time compatibility and convenience helper' \
    /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

Code repositories for project(s) associated with this inbox:

	https://git.savannah.gnu.org/cgit/emacs/org-mode.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).