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

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

Re: How to: 96 bit Date-time arithmetic?


From: Christian Lemburg
Subject: Re: How to: 96 bit Date-time arithmetic?
Date: 04 Sep 2002 09:57:02 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands)

"Siegfried Heintze" <address@hidden> writes:

> How do I add delta times and subtract absolute times stored in the 96 bit (3
> integer) format? Apparently the functions encode and decode will help me
> convert to and from the 96 bit time format.
> 
> I want to increment times by 1 day and have emacs properly figure out when
> there is a Feb 28.


(defun my-emacs-time->seconds (time)
  "Convert emacs time format to seconds as one 32 bit integer."
  (let ((high (lsh (car time) 16))
        (low (cadr time)))
    (logior high low)))

(defun my-seconds->emacs-time (time)
  "Convert one 32 bit integer to emacs time format."
  (list (lsh time -16) (logand time (1- (lsh 1 16))) 0))


-- 
Christian Lemburg, <address@hidden>, http://www.clemburg.com/
 Hand, n.:
        A singular instrument worn at the end of a human arm and
 commonly thrust into somebody's pocket.
                -- Ambrose Bierce, "The Devil's Dictionary"


reply via email to

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