Subversion Repositories DevTools

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2875 dpurdie 1
#pragma force_top_level
2
#pragma include_only_once
3
 
4
/* time.h: ANSI 'C' (X3J11 Oct 88) library header, section 4.12 */
5
/* Copyright (C) Codemist Ltd., 1988-1993.                      */
6
/* Copyright (C) Advanced Risc Machines Ltd., 1991-1993.        */
7
/* version 0.03 */
8
 
9
/*
10
 * time.h declares two macros, four types and several functions for
11
 * manipulating time. Many functions deal with a calendar time that represents
12
 * the current date (according to the Gregorian calendar) and time. Some
13
 * functions deal with local time, which is the caledar time expressed for some
14
 * specific time zone, and with Dalight Savings Time, which is a temporary
15
 * change in the algorithm for determining local time.
16
 */
17
 
18
#ifndef __time_h
19
#define __time_h
20
 
21
#ifdef __cplusplus
22
extern "C" {
23
#endif
24
 
25
#ifndef __size_t
26
#define __size_t 1
27
typedef unsigned int size_t;   /* from <stddef.h> */
28
#endif
29
 
30
#ifndef NULL
31
#  define NULL 0
32
#endif
33
 
34
#ifdef __CLK_TCK
35
#  define CLK_TCK         __CLK_TCK    /* Pre-Dec 88 Draft; under threat */
36
#  define CLOCKS_PER_SEC  __CLK_TCK    /* Dec 1988 Draft                 */
37
#else
38
#  define CLK_TCK         100          /* for the BBC                    */
39
#  define CLOCKS_PER_SEC  100          /* for the BBC                    */
40
   /* the number per second of the value returned by the clock function. */
41
#endif
42
 
43
typedef unsigned int clock_t;    /* cpu time type - in centisecs on bbc  */
44
typedef unsigned int time_t;     /* date/time in unix secs past 1-Jan-70 */
45
 
46
struct tm {
47
  int tm_sec;   /* seconds after the minute, 0 to 60
48
                   (0 - 60 allows for the occasional leap second) */
49
  int tm_min;   /* minutes after the hour, 0 to 59 */
50
  int tm_hour;  /* hours since midnight, 0 to 23 */
51
  int tm_mday;  /* day of the month, 1 to 31 */
52
  int tm_mon;   /* months since January, 0 to 11 */
53
  int tm_year;  /* years since 1900 */
54
  int tm_wday;  /* days since Sunday, 0 to 6 */
55
  int tm_yday;  /* days since January 1, 0 to 365 */
56
  int tm_isdst; /* Daylight Savings Time flag */
57
};
58
   /* struct tm holds the components of a calendar time, called the broken-down
59
    * time. The value of tm_isdst is positive if Daylight Savings Time is in
60
    * effect, zero if Daylight Savings Time is not in effect, and negative if
61
    * the information is not available.
62
    */
63
 
64
extern clock_t clock(void);
65
   /* determines the processor time used.
66
    * Returns: the implementation's best approximation to the processor time
67
    *          used by the program since program invocation. The time in
68
    *          seconds is the value returned divided by the value of the macro
69
    *          CLK_TCK. The value (clock_t)-1 is returned if the processor time
70
    *          used is not available.
71
    */
72
extern double difftime(time_t /*time1*/, time_t /*time0*/);
73
   /*
74
    * computes the difference between two calendar times: time1 - time0.
75
    * Returns: the difference expressed in seconds as a double.
76
    */
77
extern time_t mktime(struct tm * /*timeptr*/);
78
   /*
79
    * converts the broken-down time, expressed as local time, in the structure
80
    * pointed to by timeptr into a calendar time value with the same encoding
81
    * as that of the values returned by the time function. The original values
82
    * of the tm_wday and tm_yday components of the structure are ignored, and
83
    * the original values of the other components are not restricted to the
84
    * ranges indicated above. On successful completion, the values of the
85
    * tm_wday and tm_yday structure components are set appropriately, and the
86
    * other components are set to represent the specified calendar time, but
87
    * with their values forced to the ranges indicated above; the final value
88
    * of tm_mday is not set until tm_mon and tm_year are determined.
89
    * Returns: the specified calendar time encoded as a value of type time_t.
90
    *          If the calendar time cannot be represented, the function returns
91
    *          the value (time_t)-1.
92
    */
93
extern time_t time(time_t * /*timer*/);
94
   /*
95
    * determines the current calendar time. The encoding of the value is
96
    * unspecified.
97
    * Returns: the implementations best approximation to the current calendar
98
    *          time. The value (time_t)-1 is returned if the calendar time is
99
    *          not available. If timer is not a null pointer, the return value
100
    *          is also assigned to the object it points to.
101
    */
102
 
103
extern char *asctime(const struct tm * /*timeptr*/);
104
   /*
105
    * converts the broken-down time in the structure pointed to by timeptr into
106
    * a string in the form Sun Sep 16 01:03:52 1973\n\0.
107
    * Returns: a pointer to the string containing the date and time.
108
    */
109
extern char *ctime(const time_t * /*timer*/);
110
   /*
111
    * converts the calendar time pointed to by timer to local time in the form
112
    * of a string. It is equivalent to asctime(localtime(timer));
113
    * Returns: the pointer returned by the asctime function with that
114
    *          broken-down time as argument.
115
    */
116
extern struct tm *gmtime(const time_t * /*timer*/);
117
   /*
118
    * converts the calendar time pointed to by timer into a broken-down time,
119
    * expressed as Greenwich Mean Time (GMT).
120
    * Returns: a pointer to that object or a null pointer if GMT not available.
121
    */
122
extern struct tm *localtime(const time_t * /*timer*/);
123
   /*
124
    * converts the calendar time pointed to by timer into a broken-down time,
125
    * expressed a local time.
126
    * Returns: a pointer to that object.
127
    */
128
extern size_t strftime(char * /*s*/, size_t /*maxsize*/,
129
                       const char * /*format*/, const struct tm * /*timeptr*/);
130
   /*
131
    * places characters into the array pointed to by s as controlled by the
132
    * string pointed to by format. The format string consists of zero or more
133
    * directives and ordinary characters. A directive consists of a % character
134
    * followed by a character that determines the directive's behaviour. All
135
    * ordinary characters (including the terminating null character) are copied
136
    * unchanged into the array. No more than maxsize characters are placed into
137
    * the array. Each directive is replaced by appropriate characters  as
138
    * described in the following list. The appropriate characters are
139
    * determined by the LC_TIME category of the current locale and by the
140
    * values contained in the structure pointed to by timeptr.
141
    * %a is replaced by the locale's abbreviated weekday name.
142
    * %A is replaced by the locale's full weekday name.
143
    * %b is replaced by the locale's abbreviated month name.
144
    * %B is replaced by the locale's full month name.
145
    * %c is replaced by the locale's appropriate date and time representation.
146
    * %d is replaced by the day of the month as a decimal number (01-31).
147
    * %H is replaced by the hour (24-hour clock) as a decimal number (00-23).
148
    * %I is replaced by the hour (12-hour clock) as a decimal number (01-12).
149
    * %j is replaced by the day of the year as a decimal number (001-366).
150
    * %m is replaced by the month as a decimal number (01-12).
151
    * %M is replaced by the minute as a decimal number (00-59).
152
    * %p is replaced by the locale's equivalent of either AM or PM designations
153
    *       associated with a 12-hour clock.
154
    * %S is replaced by the second as a decimal number (00-61).
155
    * %U is replaced by the week number of the year (Sunday as the first day of
156
    *       week 1) as a decimal number (00-53).
157
    * %w is replaced by the weekday as a decimal number (0(Sunday) - 6).
158
    * %W is replaced by the week number of the year (Monday as the first day of
159
    *       week 1) as a decimal number (00-53).
160
    * %x is replaced by the locale's appropriate date representation.
161
    * %X is replaced by the locale's appropriate time representation.
162
    * %y is replaced by the year without century as a decimal number (00-99).
163
    * %Y is replaced by the year with century as a decimal number.
164
    * %Z is replaced by the timezone name or abbreviation, or by no characters
165
    *       if no time zone is determinable.
166
    * %% is replaced by %.
167
    * If a directive is not one of the above, the behaviour is undefined.
168
    * Returns: If the total number of resulting characters including the
169
    *          terminating null character is not more than maxsize, the
170
    *          strftime function returns the number of characters placed into
171
    *          the array pointed to by s not including the terminating null
172
    *          character. otherwise, zero is returned and the contents of the
173
    *          array are indeterminate.
174
    */
175
 
176
#ifdef __cplusplus
177
}
178
#endif
179
 
180
#endif
181
 
182
/* end of time.h */