all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <embe8573@student.uu.se>
To: help-gnu-emacs@gnu.org
Subject: Re: How to get time difference with Elisp?
Date: Tue, 12 Jul 2016 13:48:09 +0200	[thread overview]
Message-ID: <86wpkrhybq.fsf@student.uu.se> (raw)
In-Reply-To: mailman.1166.1468320413.26859.help-gnu-emacs@gnu.org

Karl Voit <devnull@Karl-Voit.at> writes:

> I need to determine total office hours of
> a day without the time spent in lunch break.
> The source data is officebegin, officeend,
> lunchbreakbegin, lunchbreakend - all in
> string format "HH:MM" like "14:58".

I have two functions to that end only I think
bigger than in hours and minutes :)

But I think it can be modified to do what you
want by modifying the input arguments, the
output format, and possibly some other things
as well.

Keet it up :)

(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 "%Y, %D" seconds-diff)))

(defun get-time-since (year month day)
  (interactive "nyear: \nnmonth: \nnday: ")
  (message "%s" (format-seconds
                 "%Y, %D"
                 (float-time
                  (time-since (encode-time 0 0 0 day month year)) ))))

Source: http://user.it.uu.se/~embe8573/conf/emacs-init/time-my.el

-- 
underground experts united .... http://user.it.uu.se/~embe8573
Emacs Gnus Blogomatic ......... http://user.it.uu.se/~embe8573/blogomatic
                   - so far: 56 Blogomatic articles -                   


       reply	other threads:[~2016-07-12 11:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.1166.1468320413.26859.help-gnu-emacs@gnu.org>
2016-07-12 11:48 ` Emanuel Berg [this message]
2016-07-12 10:46 How to get time difference with Elisp? Karl Voit
2016-07-12 11:14 ` tomas
2016-07-12 11:48   ` Karl Voit
2016-07-12 12:25     ` tomas
2016-07-12 13:34 ` Karl Voit

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=86wpkrhybq.fsf@student.uu.se \
    --to=embe8573@student.uu.se \
    --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.