From ... Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!snoopy.risq.qc.ca!newsfeed.belnet.be!news.belnet.be!news.brutele.be!nmaster.kpnqwest.net!nnum.kpnqwest.net!EU.net!nreader1.kpnqwest.net.POSTED!not-for-mail Newsgroups: comp.lang.lisp Subject: Re: Lisp Date arithmetic library References: Mail-Copies-To: never From: Erik Naggum Message-ID: <3234029030120975@naggum.net> Organization: Naggum Software, Oslo, Norway Lines: 44 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Tue, 25 Jun 2002 21:23:50 GMT X-Complaints-To: newsmaster@KPNQwest.no X-Trace: nreader1.kpnqwest.net 1025040230 193.71.199.50 (Tue, 25 Jun 2002 23:23:50 MET DST) NNTP-Posting-Date: Tue, 25 Jun 2002 23:23:50 MET DST Xref: archiver1.google.com comp.lang.lisp:35723 * Bruce Lester | I am looking for Lisp code to calculate and format date values in a variety | of formats. Does anyone have suggestions on where I might look for this? It is actually too simple. First you have to forget tiemzones, because they do not generally work, not even your local one, since Common Lisp does not interface to your operating system's timezone database in any standard way and many implementations are severely confused outside the state where its authors live. That makes the whole problem a lot simpler than it really is, so you are relieved of lots of minor problems. Then you just use decoded-universal-time and bind the values like this: (multiple-value-bind (ss mm hh d m y dow dst zone) (decode-universal-time X) ...) Now, the _only_ correct way to print a date is this: (format "~4,'0D-~2,'0D-~2,'0D" y m d) and the _only_ correct way to print a time is this: (format 86400) always decomposes into a day since 1900-01-01 and the seconds the start of the current day. There are exactly 86400 seconds in a day, all year round. -- Guide to non-spammers: If you want to send me a business proposal, please be specific and do not put "business proposal" in the Subject header. If it is urgent, do not use the word "urgent". If you need an immediate answer, give me a reason, do not shout "for your immediate attention". Thank you.