Main Page | Alphabetical List | Class List | File List | Class Members | File Members

time.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------------------
00002  * /
00003  * / apeNEXT time functions for nlcc
00004  * /
00005  * / $Id: time.h,v 1.15 2005/10/27 20:04:45 morinl Exp $
00006  * /
00007  * /
00008  * / ISO/IEC 9899:1999 (E) Standard
00009  * / Date and Time  <time.h>
00010  * /
00011  * /
00012  * /
00013  * / IMPLEMENTATION for APEnext: partly possible (time.h)
00014  * /-----------------------------------------------------------------------------*/
00015 
00016 #ifndef _TIME_H
00017 #define _TIME_H
00018 
00019 #include <nlibc.h>
00020 #include <stddef.h>
00021 
00022 /*--------------------------------------------------------------------------------
00023  * /
00024  * / NULL will be defined in <stddef.h>
00025  * /
00026  * /-----------------------------------------------------------------------------*/
00027 /* #define NULL */
00028 
00029 
00030 /*---------------------------------------------------------------------------------
00031  * /
00032  * / CLOCKS_PER_SEC is usually defined as 1000000l
00033  * /
00034  * /-----------------------------------------------------------------------------*/
00035 #define CLOCKS_PER_SEC 1000000l
00036 
00037 
00038 /*---------------------------------------------------------------------------------
00039  * /
00040  * / size_t will be defined in <stddef.h>
00041  * /
00042  * /-----------------------------------------------------------------------------*/
00043 
00044 /*---------------------------------------------------------------------------------
00045  * /
00046  * / clock_t will be defined in <stddef.h>
00047  * /
00048  * /-----------------------------------------------------------------------------*/
00049 #ifndef _CLOCK_T
00050 #define _CLOCK_T
00051 
00052 typedef unsigned clock_t;
00053 
00054 #endif
00055 
00056 /*--------------------------------------------------------------------------------
00057  * /
00058  * / time_t will be defined in <stddef.h>
00059  * /
00060  * /-----------------------------------------------------------------------------*/
00061 #ifndef _TIME_T
00062 #define _TIME_T
00063 
00064 typedef unsigned time_t;
00065 
00066 #endif
00067 
00068 /*---------------------------------------------------------------------------------
00069  * /
00070  * / The tm structure holds the components of a caledar time 
00071  * / (broken down time)
00072  * /
00073  * / IMPLEMENTATION for APEnext: possible (struct tm)
00074  * /------------------------------------------------------------------------------*/
00075 struct tm 
00076 {
00077   int tm_sec;                   /* Seconds.     [0-60] (1 leap second) */
00078   int tm_min;                   /* Minutes.     [0-59] */
00079   int tm_hour;                  /* Hours.       [0-23] */
00080   int tm_mday;                  /* Day.         [1-31] */
00081   int tm_mon;                   /* Month.       [0-11] */
00082   int tm_year;                  /* Year - 1900.  */
00083   int tm_wday;                  /* Day of week. [0-6] */
00084   int tm_yday;                  /* Days in year.[0-365] */
00085   int tm_isdst;                 /* DST.         [-1/0/1]*/
00086 };
00087 
00088 /*---------------------------------------------------------------------------------
00089  * / 
00090  * / NAME
00091  * /         clock - Determine processor time
00092  * / 
00093  * / SYNOPSIS
00094  * /        #include <time.h>
00095  * / 
00096  * /       clock_t clock(void);
00097  * / 
00098  * / DESCRIPTION
00099  * /        The clock() function returns an approximation of processor 
00100  * /       time used by the program.
00101  * / 
00102  * / RETURN VALUE
00103  * /        The  value returned is the CPU time used so far as a clock_t; 
00104  * /       to get the number of seconds used, divide by CLOCKS_PER_SEC.  
00105  * /       If the processor time used is  not  available or its value 
00106  * /       cannot be represented, the function returns the value (clock_t)-1.
00107  * / 
00108  * / IMPLEMENTATION for APEnext: possible (clock)
00109  * / 
00110  * / ---------------------------------------------------------------------------*/
00111 #ifndef __HAS_MAIN
00112 extern clock_t clock(void);
00113 #else
00114 #if !defined(__cflow_processed) || defined(_uses_clock_time_h)
00115 clock_t clock(void)
00116 {
00117         return 0;
00118 }
00119 #endif
00120 #endif // Has Main
00121 
00122 /*--------------------------------------------------------------------------------
00123  * / 
00124  * / NAME
00125  * /        difftime - calculate time difference
00126  * / 
00127  * / SYNOPSIS
00128  * /        #include <time.h>
00129  * / 
00130  * /        double difftime(time_t time1, time_t time0);
00131  * / 
00132  * / DESCRIPTION
00133  * /        The  difftime() function returns the number of seconds 
00134  * /        elapsed between time time1 and time time0. The two times are 
00135  * /        specified in calendar time, which  represents  the  time
00136  * /        elapsed since 00:00:00 on January 1, 1970, Coordinated 
00137  * /        Universal Time (UTC).
00138  * / 
00139  * / IMPLEMENTATION for APEnext: possible (difftime)
00140  * / 
00141  * / ----------------------------------------------------------------------------*/
00142 #if !defined(__cflow_processed) || defined(_uses_difftime_time_h)
00143 inline double difftime(time_t time1, time_t time0)
00144 {
00145         return (double)(time1-time0);
00146 }
00147 #endif
00148 
00149 /*--------------------------------------------------------------------------------
00150  * /
00151  * / NAME
00152  * /        mktime - transforms broken-down time to calendar time
00153  * / 
00154  * / SYNOPSIS
00155  * /        #include <time.h>
00156  * / 
00157  * /        time_t mktime(struct tm *timeptr);
00158  * / 
00159  * / DESCRIPTION
00160  * /       The mktime() function converts a broken-down time structure, 
00161  * /       expressed as  local  time, to  calendar  time  representation.  
00162  * /       The function ignores the specified contents of the structure 
00163  * /       members tm_wday and tm_yday and recomputes them from the other 
00164  * /       information in the broken-down time structure.  If structure 
00165  * /       members are outside their legal interval, they will be normalized 
00166  * /       (so that, e.g., 40 October is changed into 9 November). 
00167  * /       Calling mktime() also sets the external variable tzname with 
00168  * /       information about the current time zone.  If the specified 
00169  * /       broken-down time cannot be represented  as  calendar  time 
00170  * /       (seconds  since the epoch), mktime() returns a value of 
00171  * /       (time_t)(-1) and does not alter the tm_wday and tm_yday members 
00172  * /       of the broken-down time structure.
00173  * / 
00174  * / 
00175  * / IMPLEMENTATION for APEnext: possible (mktime)
00176  * /  
00177  * / ---------------------------------------------------------------------------*/
00178 #ifndef __HAS_MAIN
00179 extern time_t mktime(struct tm *timeptr);
00180 #else
00181 #if !defined(__cflow_processed) || defined(_uses_mktime_time_h)
00182 time_t mktime(struct tm *timeptr)
00183 {
00184         return 0;
00185 }
00186 #endif
00187 #endif // Has Main
00188 
00189 /*--------------------------------------------------------------------------------
00190  * / 
00191  * / NAME
00192  * /        time - get time in seconds
00193  * / 
00194  * / SYNOPSIS
00195  * /        #include <time.h>
00196  * / 
00197  * /        time_t time(time_t *t);
00198  * / 
00199  * / DESCRIPTION
00200  * /        time returns the time since the Epoch (00:00:00 UTC, January 1, 1970),
00201  * /        measured in seconds.
00202  * / 
00203  * /        If t is non-NULL, the return value is also stored in the 
00204  * /       memory pointed to by t.
00205  * / 
00206  * / RETURN VALUE
00207  * /       On success, the value of time in seconds  since  the  Epoch  
00208  * /       is  returned.   On  error,
00209  * /       ((time_t)-1) is returned, and errno is set appropriately.
00210  * / 
00211  * / ERRORS
00212  * /        EFAULT t points outside your accessible address space.
00213  * / 
00214  * /  
00215  * / IMPLEMENTATION for APEnext: possible (?) (time)
00216  * / 
00217  * / ---------------------------------------------------------------------------*/
00218 #ifndef __HAS_MAIN
00219 extern time_t time(time_t *timer);
00220 #else
00221 #if !defined(__cflow_processed) || defined(_uses_time_time_h)
00222 time_t time(time_t *timer)
00223 {
00224         return 0;
00225 }
00226 #endif
00227 #endif // Has Main
00228 
00229 /*-------------------------------------------------------------------------------
00230  * / 
00231  * / NAME
00232  * /       asctime - transforms broken-down time to a string
00233  * /  
00234  * / SYNOPSIS
00235  * /       #include <time.h>
00236  * /
00237  * /       char *asctime(const struct tm *timeptr);
00238  * /
00239  * / DESCRIPTION
00240  * /       The asctime() function converts the broken-down time value 
00241  * /       timeptr into a  string  with the  same  format as ctime().  
00242  * /       The return value points to a statically allocated string 
00243  * /       which might be overwritten by subsequent calls to any of 
00244  * /       the date and time functions.
00245  * /
00246  * / IMPLEMENTATION for APEnext: possible if strings are implemented (asctime)
00247  * / 
00248  * / ---------------------------------------------------------------------------*/
00249 #ifndef __HAS_MAIN
00250 extern char *asctime(const struct tm *timeptr);
00251 #else
00252 #if !defined(__cflow_processed) || defined(_uses_asctime_time_h)
00253 char *asctime(const struct tm *timeptr)
00254 {
00255         return NULL;
00256 }
00257 #endif
00258 #endif // Has Main
00259 
00260 /*--------------------------------------------------------------------------------
00261  * / 
00262  * / NAME
00263  * /       ctime - transforms calendar time into a string
00264  * /  
00265  * / SYNOPSIS
00266  * /       #include <time.h>
00267  * /
00268  * /       char *ctime(const time_t *timer)
00269  * /
00270  * / DESCRIPTION
00271  * /       The ctime() function converts the calendar time timep into a 
00272  * /       string of the form   "Wed Jun 30 21:49:08 1993\n"
00273  * /
00274  * /       The  abbreviations  for  the  days  of  the week are `Sun', 
00275  * /       `Mon', `Tue', `Wed', `Thu', `Fri', and `Sat'.  The abbreviations 
00276  * /       for the months are  `Jan',  `Feb',  `Mar',  `Apr', `May', `Jun', 
00277  * /       `Jul', `Aug', `Sep', `Oct', `Nov', and `Dec'.  The return value 
00278  * /       points to  a statically allocated string which might be 
00279  * /       overwritten by subsequent calls to any  of the  date and time 
00280  * /       functions.  The function also sets the external variable tzname 
00281  * /       with information about the current time zone.
00282  * /
00283  * /
00284  * / IMPLEMENTATION for APEnext: possible if strings are implemented (ctime)
00285  * / 
00286  * / ---------------------------------------------------------------------------*/
00287 #ifndef __HAS_MAIN
00288 extern char *ctime(const time_t *timer);
00289 #else
00290 #if !defined(__cflow_processed) || defined(_uses_ctime_time_h)
00291 char *ctime(const time_t *timer)
00292 {
00293         return NULL;
00294 }
00295 #endif
00296 #endif // Has Main
00297 
00298 /*--------------------------------------------------------------------------------
00299  * / 
00300  * / NAME
00301  * /       gmtime - transforms calendar time to broken-down time
00302  * /  
00303  * / SYNOPSIS
00304  * /       #include <time.h>
00305  * / 
00306  * /        struct tm *gmtime(const time_t *timep);
00307  * /
00308  * / DESCRIPTION
00309  * /       The gmtime() function converts the calendar time timep to 
00310  * /       broken-down time
00311  * /       representation, expressed in Coordinated Universal Time (UTC).
00312  * / 
00313  * / IMPLEMENTATION for APEnext: possible (gmtime)
00314  * / 
00315  * / ---------------------------------------------------------------------------*/
00316 #ifndef __HAS_MAIN
00317 extern struct tm *gmtime(const time_t *timer);
00318 #else
00319 #if !defined(__cflow_processed) || defined(_uses_gmtime_time_h)
00320 struct tm *gmtime(const time_t *timer)
00321 {
00322         return NULL;
00323 }
00324 #endif
00325 #endif // Has Main
00326 
00327 /*-------------------------------------------------------------------------------
00328  * / 
00329  * / NAME
00330  * /       localtime - transforms calendar time to broken time relative 
00331  * /       to specified time zone
00332  * / 
00333  * / SYNOPSIS
00334  * /        #include <time.h>
00335  * / 
00336  * /        struct tm *localtime(const time_t *timep);
00337  * / 
00338  * / DESCRIPTION
00339  * /       The  localtime()  function  converts the calendar time timep 
00340  * /       to broken-time representation, expressed relative to the user's 
00341  * /       specified time zone.    The  function  sets  the external  
00342  * /       variables  tzname with information about the current time zone, 
00343  * /       timezone with the difference between Coordinated Universal Time 
00344  * /       (UTC) and local standard time in seconds,  and  daylight  to  
00345  * /       a  non-zero  value if standard US daylight savings time rules
00346  * /        apply.
00347  * / 
00348  * / IMPLEMENTATION for APEnext: possible (localtime)
00349  * / 
00350  * / ---------------------------------------------------------------------------*/
00351 #ifndef __HAS_MAIN
00352 extern struct tm *localtime(const time_t *timer);
00353 #else
00354 #if !defined(__cflow_processed) || defined(_uses_localtime_time_h)
00355 struct tm *localtime(const time_t *timer)
00356 {
00357         return NULL;
00358 }
00359 #endif
00360 #endif // Has Main
00361 
00362 /*--------------------------------------------------------------------------------
00363  * / 
00364  * / NAME
00365  * /        strftime - format date and time
00366  * / 
00367  * / SYNOPSIS
00368  * /        #include <time.h>
00369  * / 
00370  * /        size_t strftime(char *s, size_t max, const char *format,
00371  * /                            const struct tm *tm);
00372  * / 
00373  * / DESCRIPTION
00374  * /       The  strftime() function formats the broken-down time tm according 
00375  * /       to the format specification format and places the result in the 
00376  * /       character array s of size max.
00377  * / 
00378  * / IMPLEMENTATION for APEnext: possible if strings are implemented (strftime)
00379  * / 
00380  * / ----------------------------------------------------------------------------*/
00381 #ifndef __HAS_MAIN
00382 extern size_t strftime(char * restrict s, size_t maxsize, const char * restrict format);
00383 #else
00384 #if !defined(__cflow_processed) || defined(_uses_strftime_time_h)
00385 size_t strftime(char * restrict s, size_t maxsize, const char * restrict format,
00386                 const struct tm * restrict timeptr)
00387 {
00388         return 0;
00389 }
00390 #endif
00391 #endif // Has Main
00392 
00393 #endif /* ifndef _TIME_H  */

Generated on Fri Jul 14 10:51:32 2006 for nlibc by doxygen 1.3.5