1 /* $OpenBSD: time.h,v 1.15 2003/06/26 19:34:17 avsm Exp $ */ 2 /* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */ 3 4 /* 5 * Copyright (c) 1989 The Regents of the University of California. 6 * All rights reserved. 7 * 8 * (c) UNIX System Laboratories, Inc. 9 * All or some portions of this file are derived from material licensed 10 * to the University of California by American Telephone and Telegraph 11 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 12 * the permission of UNIX System Laboratories, Inc. 13 * 14 * Redistribution and use in source and binary forms, with or without 15 * modification, are permitted provided that the following conditions 16 * are met: 17 * 1. Redistributions of source code must retain the above copyright 18 * notice, this list of conditions and the following disclaimer. 19 * 2. Redistributions in binary form must reproduce the above copyright 20 * notice, this list of conditions and the following disclaimer in the 21 * documentation and/or other materials provided with the distribution. 22 * 3. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)time.h 5.12 (Berkeley) 3/9/91 39 */ 40 41 #ifndef _TIME_H_ 42 #define _TIME_H_ 43 44 #include <machine/ansi.h> 45 46 #ifndef NULL 47 #ifdef __GNUG__ 48 #define NULL __null 49 #else 50 #define NULL 0L 51 #endif 52 #endif 53 54 #ifdef _BSD_CLOCK_T_ 55 typedef _BSD_CLOCK_T_ clock_t; 56 #undef _BSD_CLOCK_T_ 57 #endif 58 59 #ifdef _BSD_TIME_T_ 60 typedef _BSD_TIME_T_ time_t; 61 #undef _BSD_TIME_T_ 62 #endif 63 64 #ifdef _BSD_SIZE_T_ 65 typedef _BSD_SIZE_T_ size_t; 66 #undef _BSD_SIZE_T_ 67 #endif 68 69 #define CLOCKS_PER_SEC 100 70 71 struct tm { 72 int tm_sec; /* seconds after the minute [0-60] */ 73 int tm_min; /* minutes after the hour [0-59] */ 74 int tm_hour; /* hours since midnight [0-23] */ 75 int tm_mday; /* day of the month [1-31] */ 76 int tm_mon; /* months since January [0-11] */ 77 int tm_year; /* years since 1900 */ 78 int tm_wday; /* days since Sunday [0-6] */ 79 int tm_yday; /* days since January 1 [0-365] */ 80 int tm_isdst; /* Daylight Saving Time flag */ 81 long tm_gmtoff; /* offset from UTC in seconds */ 82 char *tm_zone; /* timezone abbreviation */ 83 }; 84 85 #include <sys/cdefs.h> 86 87 __BEGIN_DECLS 88 struct timespec; 89 char *asctime(const struct tm *); 90 clock_t clock(void); 91 char *ctime(const time_t *); 92 double difftime(time_t, time_t); 93 struct tm *gmtime(const time_t *); 94 struct tm *localtime(const time_t *); 95 time_t mktime(struct tm *); 96 size_t strftime(char *, size_t, const char *, const struct tm *); 97 char *strptime(const char *, const char *, struct tm *); 98 time_t time(time_t *); 99 char *asctime_r(const struct tm *, char *); 100 char *ctime_r(const time_t *, char *); 101 struct tm *gmtime_r(const time_t *, struct tm *); 102 struct tm *localtime_r(const time_t *, struct tm *); 103 int nanosleep(const struct timespec *, struct timespec *); 104 105 #if !defined(_ANSI_SOURCE) 106 #define CLK_TCK 100 107 extern char *tzname[2]; 108 void tzset(void); 109 #endif /* not ANSI */ 110 111 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 112 char *timezone(int, int); 113 void tzsetwall(void); 114 time_t timelocal(struct tm *); 115 time_t timegm(struct tm *); 116 time_t timeoff(struct tm *, const long); 117 #endif /* neither ANSI nor POSIX */ 118 __END_DECLS 119 120 #endif /* !_TIME_H_ */ 121