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