From: Sam Steingold
Subject: DECODE-UNIVERSAL-TIME as the inverse of ENCODE-UNIVERSAL-TIME
Date: 
Message-ID: <u4qa8fgvq.fsf@gnu.org>
if this functions supposed to return NIL for all inputs?

(defun check-universal-time (time &optional tz)
  (multiple-value-bind (se mi ho da mo ye) (decode-universal-time time tz)
    (let ((ut (encode-universal-time se mi ho da mo ye tz)))
      (unless (= ut time)
        (list time (list se mi ho da mo ye tz) ut (- ut time))))))

when TZ is non-NIL, the answer is obviously yes.
what happens when the default timezone is used?
[assuming that decode-universal-time & encode-universal-time treat
tz=NIL as missing]

-- 
Sam Steingold (http://www.podval.org/~sds) running w2k
<http://www.dhimmi.com/> <http://ffii.org/> <http://www.palestinefacts.org/>
<http://www.jihadwatch.org/> <http://pmw.org.il/>
Single tasking: Just Say No.
From: Pascal Bourguignon
Subject: Re: DECODE-UNIVERSAL-TIME as the inverse of ENCODE-UNIVERSAL-TIME
Date: 
Message-ID: <8764uo47m6.fsf@thalassa.informatimago.com>
Sam Steingold <ยทยทยท@gnu.org> writes:

> if this functions supposed to return NIL for all inputs?
>
> (defun check-universal-time (time &optional tz)
>   (multiple-value-bind (se mi ho da mo ye) (decode-universal-time time tz)
>     (let ((ut (encode-universal-time se mi ho da mo ye tz)))
>       (unless (= ut time)
>         (list time (list se mi ho da mo ye tz) ut (- ut time))))))
>
> when TZ is non-NIL, the answer is obviously yes.
> what happens when the default timezone is used?
> [assuming that decode-universal-time & encode-universal-time treat
> tz=NIL as missing]

Don't assume:

(defun check-universal-time (time &optional (tz nil tz-p))
  (multiple-value-bind (se mi ho da mo ye)
      (apply (function decode-universal-time) time (when tz-p (list tz)))
    (let ((ut (apply (function encode-universal-time) se mi ho da mo ye
                      (when tz-p (list tz)))))
      (unless (= ut time)
        (list time (list se mi ho da mo ye tz) ut (- ut time))))))



Some input raise an error: universal times are positive integers, and
the time zone can shift a positive integer before 1/1/1900 00:00:00.

[26]> (CHECK-UNIVERSAL-TIME 1000 6)

*** - incorrect date: 31.12.1899, 18h16m40s, time zone 6



-- 
"You question the worthiness of my code? I should kill you where you
stand!"