home *** CD-ROM | disk | FTP | other *** search
- /*
- (C) 1995-96 AROS - The Amiga Replacement OS
- $Id: time.c,v 1.1 1997/01/29 16:51:35 digulla Exp $
-
- Desc: Return the current time in seconds
- Lang: english
- */
-
- #include <dos/dos.h>
- #include <proto/dos.h>
-
- long __gmtoffset;
-
- /*****************************************************************************
-
- NAME */
- #include <time.h>
-
- time_t time (
-
- /* SYNOPSIS */
- time_t * tloc)
-
- /* FUNCTION
- time() returns the time since 00:00:00 GMT, January 1, 1970,
- measured in seconds.
-
- INPUTS
- tloc - If this pointer is non-NULL, then the time is written into
- this variable as well.
-
- RESULT
- The number of seconds.
-
- NOTES
-
- EXAMPLE
- time_t tt1, tt2;
-
- // tt1 and tt2 are the same
- tt1 = time (&tt2);
-
- // This is valid, too
- tt1 = time (NULL);
-
- BUGS
-
- SEE ALSO
- ctime(), asctime(), localtime()
-
- INTERNALS
-
- HISTORY
- 29.01.1997 digulla created
-
- ******************************************************************************/
- {
- struct DateStamp t;
- time_t tt;
-
- DateStamp (&t); /* Get timestamp */
-
- /*
- 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap
- years and 6 normal). The former number is the start value
- for time(), the latter the start time for the AmigaOS
- time functions.
- 1440 is the number of minutes per day
- 60 is the number of seconds per minute
- */
- tt = ((t.ds_Days + 2922) * 1440 + t.ds_Minute + __gmtoffset) * 60
- + t.ds_Tick / TICKS_PER_SECOND;
-
- if (tloc != NULL)
- *tloc = tt;
-
- return tt;
- } /* time */
-
-