home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.lisp.mcl
- Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!prodigy.bc.ca!news
- From: Steve Wart <swart@prodigy.bc.ca>
- Subject: International Utilities Problems
- Message-ID: <1992Jul27.191229.3014@prodigy.bc.ca>
- Sender: news@prodigy.bc.ca
- Organization: PTC Vancouver
- X-Useragent: Nuntius v1.0
- Date: Mon, 27 Jul 1992 19:12:29 GMT
- Lines: 66
-
-
- [Excuse me if this is a repost, but our news server went down during my
- first attempt...]
-
- I've been trying to write a function that will display the current date
- in one of
- three optional formats (the same as those returned by the International
- Utilities
- function, IUDatePString, in fact). The following bits of code represent
- my attempts
- so far:
-
- ;;
- ;; The constants $shortDate, $longDate and $abbrevDate are not defined
- ;; in packages.lisp.
-
- (defconstant $shortDate 0)
- (defconstant $longDate 1)
- (defconstant $abbrevDate 2)
-
- (defun secs2date (seconds &optional (date-format $shortDate))
- ;;
- ;; Return a string representing the date of the argument, as specified
- ;; by the parameter, seconds. The optional parameter, format, can be
- ;; given as $shortDate, $longDate, or $abbrevDate, with the default
- being
- ;; $shortDate.
- ;;
- (let ((intlH (#_IUGetIntl (cond ((eql date-format $shortDate) 0)
- ((eql date-format $longDate) 1)
- ((eql date-format $abbrevDate) 1)
- (t (error "Invalid date format: ~S"
- date-format))))))
- (with-returned-pstrs ((date-string ""))
- (unwind-protect
- (progn
- (#_IUDatePString seconds date-format date-string intlH)
- (%get-string date-string))
- (#_ReleaseResource intlH)))))
-
- (defun show-date (&optional (date-format $shortDate))
- (let ((s (#_NewPtr 4)))
- (unwind-protect
- (progn
- (#_ReadDateTime s)
- (secs2date (%get-long s) date-format))
- (#_DisposPtr s))))
-
- The problem is that while (show-date $shortDate) returns the expected
- result of
- "7/27/92", (show-date $longDate) and (show-date $abbrevDate) both return
- the
- string "72792", not exactly what I had in mind. Furthermore, when I
- change the
- dateOrder field in the Intl0Rec to specify ydm, it still returns the
- string in
- the order dmy.
-
- The _IUTimePString trap works as advertised, but the date routine is
- driving me
- up a wall. Does anyone have any idea what the problem is?
-
- Steve Wart
- PTC, Vancouver
- swart@prodigy.bc.ca
- (604) 687-4636
-