add a missing section header table index conversion
[tangerine.git] / compiler / clib / time.c
blob88204175111869459b8d903e435e59656f91a7b9
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Return the current time in seconds.
6 */
8 #include <dos/dos.h>
9 #include <proto/dos.h>
11 long __gmtoffset;
13 /*****************************************************************************
15 NAME */
16 #include <time.h>
18 time_t time (
20 /* SYNOPSIS */
21 time_t * tloc)
23 /* FUNCTION
24 time() returns the time since 00:00:00 GMT, January 1, 1970,
25 measured in seconds.
27 INPUTS
28 tloc - If this pointer is non-NULL, then the time is written into
29 this variable as well.
31 RESULT
32 The number of seconds.
34 NOTES
35 This function must not be used in a shared library or
36 in a threaded application.
38 EXAMPLE
39 time_t tt1, tt2;
41 // tt1 and tt2 are the same
42 tt1 = time (&tt2);
44 // This is valid, too
45 tt1 = time (NULL);
47 BUGS
49 SEE ALSO
50 ctime(), asctime(), localtime()
52 INTERNALS
54 ******************************************************************************/
56 struct DateStamp t;
57 time_t tt;
59 DateStamp (&t); /* Get timestamp */
62 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap
63 years and 6 normal). The former number is the start value
64 for time(), the latter the start time for the AmigaOS
65 time functions.
66 1440 is the number of minutes per day
67 60 is the number of seconds per minute
69 tt = ((t.ds_Days + 2922) * 1440 + t.ds_Minute + __gmtoffset) * 60
70 + t.ds_Tick / TICKS_PER_SECOND;
72 if (tloc != NULL)
73 *tloc = tt;
75 return tt;
76 } /* time */