unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: steve-humphreys@gmx.com
To: moasenwood@zoho.eu
Cc: help-gnu-emacs@gnu.org
Subject: Re: Elisp - Function returning a list
Date: Wed, 16 Dec 2020 06:20:35 +0100	[thread overview]
Message-ID: <trinity-db17312e-55f5-4892-80aa-7fa06d098f9b-1608096034987@3c-app-mailcom-bs15> (raw)
In-Reply-To: <87o8iu8igd.fsf@zoho.eu>

> Sent: Wednesday, December 16, 2020 at 5:48 AM
> From: "Emanuel Berg via Users list for the GNU Emacs text editor" <help-gnu-emacs@gnu.org>
> To: help-gnu-emacs@gnu.org
> Subject: Re: Elisp - Function returning a list
>
> Yuri Khan wrote:
>
> >> For me 800 is 8 O'Clock
> >
> > You cannot just do decimal arithmetics on times written in
> > that format.
> >
> > Start: 800  End: 1100  Skip: 45
> > Expected: 800 845 930 1015 1100
> > Actual: 800 845 890 935 980 1025 1070
>
> Arithmetics on time? Is that the purpose?

Yes, to set the agenda time grid.

> If so, check out this:
>
> ;;; -*- lexical-binding: t -*-
> ;;;
> ;;; this file:
> ;;;   http://user.it.uu.se/~embe8573/emacs-init/time-cmp.el
> ;;;   https://dataswamp.org/~incal/emacs-init/time-cmp.el
>
> (defun wall-clock-time (h1 m1 s1 h2 m2 s2)
>   (let*((d   08) ; arbitrary day to use below, any would do
>         (m   05) ; actually something cool happened that day
>         (y 1978) ; in the history of climbing
>         (total-seconds-1 (float-time (encode-time s1 m1 h1 d m y)))
>         (total-seconds-2 (float-time (encode-time s2 m2 h2 d m y)))
>         (s-diff (- total-seconds-2 total-seconds-1)) )
>     (format-seconds "%.2h:%.2m:%.2s" s-diff) ))
> (defalias 'wct #'wall-clock-time)
> ;; (wct 09 35 10 23 00 00) ; 13:24:50
> ;; (wct 09 35 10 09 35 20) ; 00:00:10
>
> (defun time-between-times (year1 month1 day1
>                            year2 month2 day2)
>   (let*((seconds-then  (float-time (encode-time 0 0 0 day1 month1 year1)))
>         (seconds-now   (float-time (encode-time 0 0 0 day2 month2 year2)))
>         (seconds-diff  (- seconds-now seconds-then)) )
>     (format-seconds "%yy %dd" seconds-diff)))
> ;;   (time-between-times 1958  4 13 1958 8 30) ; Tahiti Nui 2 -> 3,
> ;;                                             ; i.e. 0y 139d
>
> (defun get-time-since (year month day)
>   (interactive "nyear: \nnmonth: \nnday: ")
>   (message "%s"
>            (format-seconds
>             "%yy %dd"
>             (float-time
>              (time-since (encode-time 0 0 0 day month year)) ))))
> ;; (get-time-since 2011 09 27) ; 8y 228d @ 2020-05-10
>
> --
> underground experts united
> http://user.it.uu.se/~embe8573
> https://dataswamp.org/~incal
>
>
>



  reply	other threads:[~2020-12-16  5:20 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 [this message]
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
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=trinity-db17312e-55f5-4892-80aa-7fa06d098f9b-1608096034987@3c-app-mailcom-bs15 \
    --to=steve-humphreys@gmx.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=moasenwood@zoho.eu \
    /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.
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).