help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to get time difference with Elisp?


From: Emanuel Berg
Subject: Re: How to get time difference with Elisp?
Date: Tue, 12 Jul 2016 13:48:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Karl Voit <address@hidden> 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 via email to

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