emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DRAFT][PATCH] org-encode-time compatibility and convenience helper


From: Ihor Radchenko
Subject: Re: [DRAFT][PATCH] org-encode-time compatibility and convenience helper
Date: Sat, 23 Apr 2022 16:25:00 +0800

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]