emacs-devel
[Top][All Lists]
Advanced

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

Re: [Emacs-diffs] master 46df7bb 03/12: Add new function time-zone-forma


From: Basil L. Contovounesios
Subject: Re: [Emacs-diffs] master 46df7bb 03/12: Add new function time-zone-format
Date: Thu, 01 Aug 2019 02:20:26 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

address@hidden (Lars Ingebrigtsen) writes:

> branch: master
> commit 46df7bbe12cce4c9af7ce4357aa9f8d36c1d8933
> Author: Lars Ingebrigtsen <address@hidden>
> Commit: Lars Ingebrigtsen <address@hidden>
>
>     Add new function time-zone-format
>     

[...]

> +(defun time-zone-format (seconds)
> +  "Format SECONDS as a valid time zone string.
> +For instance, 3600 is \"+01:00\"."
> +  (format "%s%02d:%02d"
> +          (if (< seconds 0)
> +              "-"
> +            "+")
> +          (/ (abs seconds) 3600)
> +          (mod (abs seconds) 3600)))
> +

Can't this (and its extension in a subsequent commit) be written in
terms of, or replaced by, format-time-string?

(format-time-string "%:z" nil  3600) ; => "+01:00"
(format-time-string "%:z" nil -7200) ; => "-02:00"
(format-time-string "%z"  nil  3600) ; => "+0100"
(format-time-string "%z"  nil -7200) ; => "-0200"

Thanks,

-- 
Basil



reply via email to

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