[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Elisp - Function returning a sequence of times
From: |
steve-humphreys |
Subject: |
Re: Elisp - Function returning a sequence of times |
Date: |
Wed, 16 Dec 2020 10:05:54 +0100 |
I have done something like this, but need help to finalise the actual function.
Do you agree on this solution?
(defun timfutur ()
(interactive)
(setq tm 845)
(setq tsk 30)
(setq thr (/ tm 100))
(setq tmn (- tm (* thr 100)))
(setq tmn-futur (% (+ tmn tsk) 60))
(setq thr-futur (% (+ (/ (+ tmn tsk) 60) thr) 24))
(message "%d %d %d%d" thr tmn thr-futur tmn-futur))
> Sent: Wednesday, December 16, 2020 at 9:01 AM
> From: "Jean Louis" <bugs@gnu.support>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a sequence of times
>
> * Emanuel Berg via Users list for the GNU Emacs text editor
> <help-gnu-emacs@gnu.org> [2020-12-16 08:53]:
> > Jean Louis wrote:
> >
> > > I am using external tools
> >
> > Me too, here is some zsh:
> >
> > https://dataswamp.org/~incal/conf/.zsh/time
> >
> > and a screenshot:
> >
> > https://dataswamp.org/~incal/pimgs/comp/clocks.png
>
> Looks like prompt, is it? Huge calendar prompt. OK fine. Could be also
> used to show upcoming appointments.
>
> Emacs must have those date/time features and adding times
> somewhere. But where?
>
> (info "(elisp) Time Calculations")
>
> time-add is a built-in function in ‘src/timefns.c’.
>
> (time-add A B)
>
> In the manual there is more references:
>
> (let ((time (decode-time nil nil t))
> (delta (make-decoded-time :month 2)))
> (encode-time (decoded-time-add time delta)))
>
> (make-decoded-time :hour 10 :minute 20) => (nil 20 10 nil nil nil nil nil nil)
>
> This adds 360 seconds to current-time:
> (time-add (current-time) 360)
>
> (defun my-days (days)
> "Returns seconds for days"
> (* 24 3600 days))
>
> (defun my-minutes (minutes)
> "Returns seconds for minutes"
> (* 60 minutes))
>
> (my-minutes 35)
> 2100
>
> (format-time-string "%H:%M" (current-time))
> "10:57"
>
> (time-add (current-time) (my-minutes 35))
> (24537 50767 754967 229000)
>
> (format-time-string "%H:%M" (time-add (current-time) (my-minutes 35)))
> "11:33"
>
> So adding works in plain Emacs.
>
> What I do not know is how to convert 10:57 time to TIME format
> like: (24537 50767 754967 229000)
>
> And because function requires only time as hours and minutes, the
> date would not matter.
>
> Once that is found, how to convert any TIME:MINUTES to that TIME
> format: (24537 50767 754967 229000) then it will be easy to make
> function that adds minutes or specified hours or minutes to it
> and produces a sequence.
>
> Jean
>
>
>
>
- Re: let, let*, oh, why [was: Elisp - Function returning a list], (continued)
- Re: let, let*, oh, why [was: Elisp - Function returning a list], Christopher Dimech, 2020/12/26
- Re: let, let*, oh, why [was: Elisp - Function returning a list], Byung-Hee HWANG, 2020/12/26
- Re: Elisp - Function returning a list, steve-humphreys, 2020/12/15
- Re: Elisp - Function returning a list, steve-humphreys, 2020/12/16
- Re: Elisp - Function returning a list, Jean Louis, 2020/12/16
- Re: Elisp - Function returning a list, Emanuel Berg, 2020/12/16
- Re: Elisp - Function returning a sequence of times, Jean Louis, 2020/12/16
- Re: Elisp - Function returning a sequence of times,
steve-humphreys <=
- Re: Elisp - Function returning a sequence of times, Joost Kremers, 2020/12/16
- Re: Elisp - Function returning a sequence of times, steve-humphreys, 2020/12/16
- Re: Elisp - Function returning a sequence of times, Michael Heerdegen, 2020/12/16
Re: Elisp - Function returning a list, Emanuel Berg, 2020/12/15