home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18359 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  1.3 KB

  1. Path: sparky!uunet!munnari.oz.au!goanna!ok
  2. From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Yet another time.h question (organisation of struct tm)
  5. Keywords: organisation of struct tm
  6. Message-ID: <16228@goanna.cs.rmit.oz.au>
  7. Date: 15 Dec 92 03:43:38 GMT
  8. References: <1g8chcINNenv@almaak.usc.edu>
  9. Organization: Comp Sci, RMIT, Melbourne, Australia
  10. Lines: 22
  11.  
  12. In article <1g8chcINNenv@almaak.usc.edu>, ajayshah@almaak.usc.edu (Ajay Shah) writes:
  13. > I'm trying to replace the initialisor
  14. > #define TINIT(T)  (T).tm_sec = (T).tm_min = (T).tm_hour = 0; \
  15. >     (T).tm_mday = 1; (T).tm_mon = 0; (T).tm_year = 0; \
  16. >     (T).tm_wday = -1; (T).tm_yday = -1; (T).tm_isdst = -1
  17.  
  18. > But this will only work if ANSI guarantees that the fields in the
  19. > tm struct-type come in the order I've assumed above.  Do they?
  20.  
  21. "The members ... can occur in any order."  (Plauger & Brodie)
  22.  
  23. > Is there any gain from using memcpy here, or is the painful
  24. > element-by-element initialisation quite fine?
  25.  
  26. Wouldn't it be more efficient still to represent dates as time_t's,
  27. and set up your default_time value using the result of mktime()?
  28.  
  29. > (A 100% C programmer who still likes the Pascal ability to say a:=b
  30. > even when a and b are records :-)).
  31.  
  32. C has had that ability for many years.
  33.