all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: steve-humphreys@gmx.com
To: Jean Louis <bugs@gnu.support>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Elisp - Function returning a sequence of times
Date: Wed, 16 Dec 2020 10:05:54 +0100	[thread overview]
Message-ID: <trinity-e60c37f7-4913-4143-b565-1286162bf883-1608109554213@3c-app-mailcom-bs15> (raw)
In-Reply-To: <X9m+z8y/6jVfZtSG@protected.rcdrun.com>

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
> 
> 
> 
>



  reply	other threads:[~2020-12-16  9:05 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16  3:25 Elisp - Function returning a list steve-humphreys
2020-12-16  4:09 ` Jean Louis
2020-12-16  4:17   ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  5:04     ` steve-humphreys
2020-12-16  5:39       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  7:36         ` steve-humphreys
2020-12-16  8:55           ` Joost Kremers
2020-12-16 10:25           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16 11:52           ` let, let*, oh, why [was: Elisp - Function returning a list] tomas
2020-12-16 14:13             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16 15:10               ` Jean Louis
2020-12-16 15:58                 ` Stefan Monnier
2020-12-16 18:37                   ` Jean Louis
2020-12-16 19:04                     ` Stefan Monnier
2020-12-16 20:05                       ` Jean Louis
2020-12-16 20:34                         ` tomas
2020-12-16 20:06                       ` tomas
2020-12-18 15:08                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-18 14:27                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-18 17:42                   ` Jean Louis
2020-12-18 20:57                     ` Eli Zaretskii
2020-12-20  4:49                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20  5:06                       ` Thien-Thi Nguyen
2020-12-20  7:02                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20  7:16                           ` Thien-Thi Nguyen
2020-12-21  2:34                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-20 13:38                           ` Jean Louis
2020-12-20  6:21                       ` Jean Louis
2020-12-20 23:20                       ` Drew Adams
2020-12-21  4:50                         ` Jean Louis
2020-12-21  5:40                           ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-21  9:17                             ` tomas
2020-12-21 15:20                               ` Drew Adams
2020-12-21 15:50                                 ` tomas
2020-12-25 14:41                       ` 황병희
2020-12-26  4:22                         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  6:18                           ` Jean Louis
2020-12-26  6:33                             ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  7:07                               ` Christopher Dimech
2020-12-26  9:53                               ` Jean Louis
2020-12-26 10:11                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  9:53                               ` Jean Louis
2020-12-26 10:20                                 ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-27  9:11                                   ` Byung-Hee HWANG
2020-12-27 11:52                                     ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-27 11:56                                       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-26  6:44                           ` Byung-Hee HWANG
2020-12-16  4:30   ` Elisp - Function returning a list steve-humphreys
2020-12-16  4:38     ` Yuri Khan
2020-12-16  4:48       ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  5:20         ` steve-humphreys
2020-12-16  5:18       ` steve-humphreys
2020-12-16  5:33       ` Jean Louis
2020-12-16  5:42         ` Emanuel Berg via Users list for the GNU Emacs text editor
2020-12-16  8:01           ` Elisp - Function returning a sequence of times Jean Louis
2020-12-16  9:05             ` steve-humphreys [this message]
2020-12-16  9:20               ` Joost Kremers
2020-12-16  9:40                 ` steve-humphreys
2020-12-16 21:54             ` Michael Heerdegen
2020-12-16  4:13 ` Elisp - Function returning a list Emanuel Berg via Users list for the GNU Emacs text editor

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

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

  git send-email \
    --in-reply-to=trinity-e60c37f7-4913-4143-b565-1286162bf883-1608109554213@3c-app-mailcom-bs15 \
    --to=steve-humphreys@gmx.com \
    --cc=bugs@gnu.support \
    --cc=help-gnu-emacs@gnu.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.