home *** CD-ROM | disk | FTP | other *** search
- /*
- tmnow.c 2/7/87
-
- % tm_Now, tm_Copy, tm_Zero
-
- Written by John Cooke.
-
- OWL 1.2
- Copyright (c) 1986-1989, by Oakland Group, Inc.
- ALL RIGHTS RESERVED.
-
- Revision History:
- -----------------
- 8/07/89 jmd Split from cstime.c
-
- 10/20/89 jmd re-wrote tm_Now (no longer uses global data)
- 3/28/90 jmd ansi-fied
- 8/01/90 ted Moved to OWL; include oaktime.h not cstime.h.
- */
-
- #include "oakhead.h"
-
- #include <time.h>
- #include "oaktime.h"
-
- struct tm *tm_Now(struct tm *t)
- /*
- DESCRIPTION:
- The tm_Now function places the current time in t.
- RETURNS:
- Returns t or NULL if t = NULL.
- */
- {
- TIME_T ltime;
- struct tm *tresult;
-
- if (t != NULL) {
-
- /* get the current time */
- time(<ime);
- tresult = localtime(<ime);
-
- /* copy time into t */
- tm_Copy(t, tresult);
-
- /* adjust the year */
- t->tm_year += 1900;
- }
-
- return(t);
- }
-
- struct tm *tm_Copy(struct tm *dest, struct tm *source)
- /*
- DESCRIPTION:
- The tm_Copy function copies the time in source to dest.
- RETURNS:
- Returns dest or NULL if either dest or source is
- equal to NULL.
- */
- {
- if (dest == NULL || source == NULL) {
- return(NULL);
- }
-
- dest->tm_sec = source->tm_sec;
- dest->tm_min = source->tm_min;
- dest->tm_hour = source->tm_hour;
- dest->tm_mday = source->tm_mday;
- dest->tm_mon = source->tm_mon;
- dest->tm_year = source->tm_year;
- dest->tm_wday = source->tm_wday;
- dest->tm_yday = source->tm_yday;
- dest->tm_isdst = source->tm_isdst;
-
- return(dest);
- }
-
-
- struct tm *tm_Zero(struct tm *t)
- /*
- DESCRIPTION:
- The tm_Zero function sets all the elements of t to 0.
- RETURNS:
- Returns t.
- */
- {
- t->tm_sec = 0;
- t->tm_min = 0;
- t->tm_hour = 0;
- t->tm_mday = 0;
- t->tm_mon = 0;
- t->tm_year = 0;
- t->tm_wday = 0;
- t->tm_yday = 0;
- t->tm_isdst = 0;
-
- return(t);
- }
-