159deaec5SRodney W. Grimes /* 259deaec5SRodney W. Grimes * Copyright (c) 1989, 1993 359deaec5SRodney W. Grimes * The Regents of the University of California. All rights reserved. 459deaec5SRodney W. Grimes * (c) UNIX System Laboratories, Inc. 559deaec5SRodney W. Grimes * All or some portions of this file are derived from material licensed 659deaec5SRodney W. Grimes * to the University of California by American Telephone and Telegraph 759deaec5SRodney W. Grimes * Co. or Unix System Laboratories, Inc. and are reproduced herein with 859deaec5SRodney W. Grimes * the permission of UNIX System Laboratories, Inc. 959deaec5SRodney W. Grimes * 1059deaec5SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 1159deaec5SRodney W. Grimes * modification, are permitted provided that the following conditions 1259deaec5SRodney W. Grimes * are met: 1359deaec5SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 1459deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 1559deaec5SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 1659deaec5SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 1759deaec5SRodney W. Grimes * documentation and/or other materials provided with the distribution. 1859deaec5SRodney W. Grimes * 3. All advertising materials mentioning features or use of this software 1959deaec5SRodney W. Grimes * must display the following acknowledgement: 2059deaec5SRodney W. Grimes * This product includes software developed by the University of 2159deaec5SRodney W. Grimes * California, Berkeley and its contributors. 2259deaec5SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 2359deaec5SRodney W. Grimes * may be used to endorse or promote products derived from this software 2459deaec5SRodney W. Grimes * without specific prior written permission. 2559deaec5SRodney W. Grimes * 2659deaec5SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2759deaec5SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2859deaec5SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2959deaec5SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3059deaec5SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3159deaec5SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3259deaec5SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3359deaec5SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3459deaec5SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3559deaec5SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3659deaec5SRodney W. Grimes * SUCH DAMAGE. 3759deaec5SRodney W. Grimes * 3859deaec5SRodney W. Grimes * @(#)time.h 8.3 (Berkeley) 1/21/94 3959deaec5SRodney W. Grimes */ 4059deaec5SRodney W. Grimes 415b32a38aSPoul-Henning Kamp /* 425b32a38aSPoul-Henning Kamp * $FreeBSD$ 435b32a38aSPoul-Henning Kamp */ 445b32a38aSPoul-Henning Kamp 4559deaec5SRodney W. Grimes #ifndef _TIME_H_ 4659deaec5SRodney W. Grimes #define _TIME_H_ 4759deaec5SRodney W. Grimes 481cb2a9aeSGarrett Wollman #include <sys/cdefs.h> 4912eb46c8SMarcel Moolenaar #include <sys/_null.h> 50abbd8902SMike Barcroft #include <sys/_types.h> 51abbd8902SMike Barcroft 5273cf72f5SGarrett Wollman #if __POSIX_VISIBLE > 0 && __POSIX_VISIBLE < 200112 || __BSD_VISIBLE 53339b0f68SBruce Evans /* 54339b0f68SBruce Evans * Frequency of the clock ticks reported by times(). Deprecated - use 551cb2a9aeSGarrett Wollman * sysconf(_SC_CLK_TCK) instead. (Removed in 1003.1-2001.) 56339b0f68SBruce Evans */ 57dd1b6791SMike Barcroft #define CLK_TCK 128 58339b0f68SBruce Evans #endif 59339b0f68SBruce Evans 60339b0f68SBruce Evans /* Frequency of the clock ticks reported by clock(). */ 61dd1b6791SMike Barcroft #define CLOCKS_PER_SEC 128 62339b0f68SBruce Evans 63abbd8902SMike Barcroft #ifndef _CLOCK_T_DECLARED 64abbd8902SMike Barcroft typedef __clock_t clock_t; 65abbd8902SMike Barcroft #define _CLOCK_T_DECLARED 6659deaec5SRodney W. Grimes #endif 6759deaec5SRodney W. Grimes 68abbd8902SMike Barcroft #ifndef _TIME_T_DECLARED 69abbd8902SMike Barcroft typedef __time_t time_t; 70abbd8902SMike Barcroft #define _TIME_T_DECLARED 7159deaec5SRodney W. Grimes #endif 7259deaec5SRodney W. Grimes 73abbd8902SMike Barcroft #ifndef _SIZE_T_DECLARED 74abbd8902SMike Barcroft typedef __size_t size_t; 75abbd8902SMike Barcroft #define _SIZE_T_DECLARED 76f154fbdaSPeter Wemm #endif 77f154fbdaSPeter Wemm 781cb2a9aeSGarrett Wollman #if __POSIX_VISIBLE >= 199309 79f154fbdaSPeter Wemm /* 80f154fbdaSPeter Wemm * New in POSIX 1003.1b-1993. 81f154fbdaSPeter Wemm */ 82abbd8902SMike Barcroft #ifndef _CLOCKID_T_DECLARED 83abbd8902SMike Barcroft typedef __clockid_t clockid_t; 84abbd8902SMike Barcroft #define _CLOCKID_T_DECLARED 859e0eb33eSAndrey A. Chernov #endif 869e0eb33eSAndrey A. Chernov 87abbd8902SMike Barcroft #ifndef _TIMER_T_DECLARED 88abbd8902SMike Barcroft typedef __timer_t timer_t; 89abbd8902SMike Barcroft #define _TIMER_T_DECLARED 9059deaec5SRodney W. Grimes #endif 9159deaec5SRodney W. Grimes 921cb2a9aeSGarrett Wollman #include <sys/timespec.h> 931cb2a9aeSGarrett Wollman #endif /* __POSIX_VISIBLE >= 199309 */ 94f154fbdaSPeter Wemm 9559deaec5SRodney W. Grimes struct tm { 9659deaec5SRodney W. Grimes int tm_sec; /* seconds after the minute [0-60] */ 9759deaec5SRodney W. Grimes int tm_min; /* minutes after the hour [0-59] */ 9859deaec5SRodney W. Grimes int tm_hour; /* hours since midnight [0-23] */ 9959deaec5SRodney W. Grimes int tm_mday; /* day of the month [1-31] */ 10059deaec5SRodney W. Grimes int tm_mon; /* months since January [0-11] */ 10159deaec5SRodney W. Grimes int tm_year; /* years since 1900 */ 10259deaec5SRodney W. Grimes int tm_wday; /* days since Sunday [0-6] */ 10359deaec5SRodney W. Grimes int tm_yday; /* days since January 1 [0-365] */ 10459deaec5SRodney W. Grimes int tm_isdst; /* Daylight Savings Time flag */ 1055b32a38aSPoul-Henning Kamp long tm_gmtoff; /* offset from UTC in seconds */ 10659deaec5SRodney W. Grimes char *tm_zone; /* timezone abbreviation */ 10759deaec5SRodney W. Grimes }; 10859deaec5SRodney W. Grimes 1091cb2a9aeSGarrett Wollman #if __POSIX_VISIBLE 1102bd32397SJoseph Koshy extern char *tzname[]; 1112bd32397SJoseph Koshy #endif 1122bd32397SJoseph Koshy 11359deaec5SRodney W. Grimes __BEGIN_DECLS 114bb28f3c2SWarner Losh char *asctime(const struct tm *); 115bb28f3c2SWarner Losh clock_t clock(void); 116bb28f3c2SWarner Losh char *ctime(const time_t *); 117bb28f3c2SWarner Losh double difftime(time_t, time_t); 118bb28f3c2SWarner Losh struct tm *gmtime(const time_t *); 119bb28f3c2SWarner Losh struct tm *localtime(const time_t *); 120bb28f3c2SWarner Losh time_t mktime(struct tm *); 121620035efSRobert Drehmel size_t strftime(char * __restrict, size_t, const char * __restrict, 122620035efSRobert Drehmel const struct tm * __restrict); 123bb28f3c2SWarner Losh time_t time(time_t *); 12459deaec5SRodney W. Grimes 1251cb2a9aeSGarrett Wollman #if __POSIX_VISIBLE 126bb28f3c2SWarner Losh void tzset(void); 1271cb2a9aeSGarrett Wollman #endif 1281cb2a9aeSGarrett Wollman 129b8c54054SGarrett Wollman #if __POSIX_VISIBLE >= 199309 130b8c54054SGarrett Wollman int clock_getres(clockid_t, struct timespec *); 131b8c54054SGarrett Wollman int clock_gettime(clockid_t, struct timespec *); 132b8c54054SGarrett Wollman int clock_settime(clockid_t, const struct timespec *); 133b8c54054SGarrett Wollman int nanosleep(const struct timespec *, struct timespec *); 134b8c54054SGarrett Wollman #endif /* __POSIX_VISIBLE >= 199309 */ 135b8c54054SGarrett Wollman 136b3ab54e1SGarrett Wollman #if __POSIX_VISIBLE >= 199506 137b3ab54e1SGarrett Wollman char *asctime_r(const struct tm *, char *); 138b3ab54e1SGarrett Wollman char *ctime_r(const time_t *, char *); 139b3ab54e1SGarrett Wollman struct tm *gmtime_r(const time_t *, struct tm *); 140b3ab54e1SGarrett Wollman struct tm *localtime_r(const time_t *, struct tm *); 141b3ab54e1SGarrett Wollman #endif 142b3ab54e1SGarrett Wollman 1431cb2a9aeSGarrett Wollman #if __XSI_VISIBLE 144d542f511SRobert Drehmel char *strptime(const char * __restrict, const char * __restrict, 145d542f511SRobert Drehmel struct tm * __restrict); 1461cb2a9aeSGarrett Wollman #endif 1471cb2a9aeSGarrett Wollman 1481cb2a9aeSGarrett Wollman #if __BSD_VISIBLE 149bb28f3c2SWarner Losh char *timezone(int, int); 150bb28f3c2SWarner Losh void tzsetwall(void); 151bb28f3c2SWarner Losh time_t timelocal(struct tm * const); 152bb28f3c2SWarner Losh time_t timegm(struct tm * const); 1531cb2a9aeSGarrett Wollman #endif /* __BSD_VISIBLE */ 15459deaec5SRodney W. Grimes __END_DECLS 15559deaec5SRodney W. Grimes 15659deaec5SRodney W. Grimes #endif /* !_TIME_H_ */ 157