home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / lisp / mcl / 1086 < prev    next >
Encoding:
Text File  |  1992-07-28  |  2.4 KB  |  78 lines

  1. Newsgroups: comp.lang.lisp.mcl
  2. Path: sparky!uunet!usc!sol.ctr.columbia.edu!destroyer!ubc-cs!unixg.ubc.ca!prodigy.bc.ca!news
  3. From: Steve Wart <swart@prodigy.bc.ca>
  4. Subject: International Utilities Problems
  5. Message-ID: <1992Jul27.191229.3014@prodigy.bc.ca>
  6. Sender: news@prodigy.bc.ca
  7. Organization: PTC Vancouver
  8. X-Useragent: Nuntius v1.0
  9. Date: Mon, 27 Jul 1992 19:12:29 GMT
  10. Lines: 66
  11.  
  12.  
  13. [Excuse me if this is a repost, but our news server went down during my
  14. first attempt...]
  15.  
  16. I've been trying to write a function that will display the current date
  17. in one of
  18. three optional formats (the same as those returned by the International
  19. Utilities
  20. function, IUDatePString, in fact).  The following bits of code represent
  21. my attempts
  22. so far:
  23.  
  24.   ;;
  25.   ;;  The constants $shortDate, $longDate and $abbrevDate are not defined
  26.   ;;  in packages.lisp.
  27.  
  28. (defconstant $shortDate 0)
  29. (defconstant $longDate 1)
  30. (defconstant $abbrevDate 2)
  31.  
  32. (defun secs2date (seconds &optional (date-format $shortDate))
  33.   ;;
  34.   ;;  Return a string representing the date of the argument, as specified
  35.   ;;  by the parameter, seconds.  The optional parameter, format, can be
  36.   ;;  given as $shortDate, $longDate, or $abbrevDate, with the default
  37. being
  38.   ;;  $shortDate.
  39.   ;;
  40.   (let ((intlH (#_IUGetIntl (cond ((eql date-format $shortDate) 0)
  41.                                   ((eql date-format $longDate) 1)
  42.                                   ((eql date-format $abbrevDate) 1)
  43.                                   (t (error "Invalid date format: ~S"
  44. date-format))))))
  45.     (with-returned-pstrs ((date-string ""))
  46.       (unwind-protect
  47.         (progn
  48.           (#_IUDatePString seconds date-format date-string intlH)
  49.           (%get-string date-string))
  50.         (#_ReleaseResource intlH)))))
  51.  
  52. (defun show-date (&optional (date-format $shortDate))
  53.   (let ((s (#_NewPtr 4)))
  54.     (unwind-protect
  55.       (progn
  56.         (#_ReadDateTime s)
  57.         (secs2date (%get-long s) date-format))
  58.       (#_DisposPtr s))))
  59.  
  60. The problem is that while (show-date $shortDate) returns the expected
  61. result of
  62. "7/27/92", (show-date $longDate) and (show-date $abbrevDate) both return
  63. the
  64. string "72792", not exactly what I had in mind.  Furthermore, when I
  65. change the
  66. dateOrder field in the Intl0Rec to specify ydm, it still returns the
  67. string in
  68. the order dmy.
  69.  
  70. The _IUTimePString trap works as advertised, but the date routine is
  71. driving me
  72. up a wall.  Does anyone have any idea what the problem is?
  73.  
  74. Steve Wart
  75. PTC, Vancouver
  76. swart@prodigy.bc.ca
  77. (604) 687-4636
  78.