From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: ken Newsgroups: gmane.emacs.help Subject: Re: variables for yesterday and today Date: Tue, 15 Oct 2002 11:15:41 -0400 (EDT) Sender: help-gnu-emacs-admin@gnu.org Message-ID: References: <87adlgw5vj.fsf@gentoo.shacknet.nu> Reply-To: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: main.gmane.org 1034695107 12896 80.91.224.249 (15 Oct 2002 15:18:27 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Tue, 15 Oct 2002 15:18:27 +0000 (UTC) Cc: Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 181TSj-0003Lk-00 for ; Tue, 15 Oct 2002 17:18:25 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 181TSf-0000LS-00; Tue, 15 Oct 2002 11:18:21 -0400 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 181TRW-0007nz-00 for help-gnu-emacs@gnu.org; Tue, 15 Oct 2002 11:17:10 -0400 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 181TRT-0007nI-00 for help-gnu-emacs@gnu.org; Tue, 15 Oct 2002 11:17:09 -0400 Original-Received: from adsl-65-43-213-176.dsl.bcvloh.ameritech.net ([65.43.213.176] helo=heidegger.mousecar.net) by monty-python.gnu.org with esmtp (Exim 4.10) id 181TPm-00076C-00 for help-gnu-emacs@gnu.org; Tue, 15 Oct 2002 11:15:22 -0400 Original-Received: from localhost (ken@localhost) by heidegger.mousecar.net (8.11.6/8.11.6) with ESMTP id g9FFFlu08031; Tue, 15 Oct 2002 11:15:47 -0400 X-Authentication-Warning: heidegger.mousecar.net: ken owned process doing -bs Original-Newsgroups: gnu.emacs.help X-X-Sender: Original-To: foomaster1200 In-Reply-To: <87adlgw5vj.fsf@gentoo.shacknet.nu> Errors-To: help-gnu-emacs-admin@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.help:2633 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:2633 foo, Thanks for the reply, but this isn't working for me. Maybe there's more to it. The problem seems to be that (<< 1 16) yeilds: "Symbol's function definition is void: <<". I'm using GNU Emacs 20.7.1 (if that could be relevant). -- AMD crashes? See http://cleveland.lug.net/~ken/amd-problem/. Spake foomaster1200 at 06:52 (UTC-0000) on Tue, 15 Oct 2002: = ken writes: = = > I'm not a great elisp coder, but figured it would be trivial to create a = > couple variables similar to current-time, but containing the values for = > yesterday and tomorrow, bzw. 'current-time - 86400 seconds' and = > 'current-time + 86400 seconds'. = > = > But it's not trivial at all, at least not how I've seen it. So before = > reinventing the wheel, has anyone coded these before? = = I'm still pretty fresh to LISP in general, but this would be my first = hack; = = ,---- = | (defun yesterday-time () = | (let ((1day-lsw (% 86400 (<< 1 16))) = | (1day-msw (/ 86400 (<< 1 16))) = | (now (current-time))) = | (list = | (+ (car now) 1day-msw) = | (+ (car (cdr now)) 1day-lsw) = | (car (cdr (cdr now)))))) = `---- = = The main thing to remember is integers in Emacs are 28 bits I guess. Emacs is saying they're 16 bits. >From "C-h f current-time": Return the current time, as the number of seconds since 1970-01-01 00:00:00. The time is returned as a list of three integers. The first has the most significant 16 bits of the seconds, while the second has the least significant 16 bits. The third integer gives the microsecond count. Thanks, ken