1 /* 2 * Copyright 2005-2010 Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _TIME_H_ 6 #define _TIME_H_ 7 8 9 #include <sys/types.h> 10 11 12 typedef __haiku_int32 clock_t; 13 typedef __haiku_int32 time_t; 14 typedef __haiku_int32 suseconds_t; 15 typedef __haiku_uint32 useconds_t; 16 17 #define CLOCKS_PER_SEC 1000 18 #define CLK_TCK CLOCKS_PER_SEC 19 20 #define MAX_TIMESTR 70 21 /* maximum length of a string returned by asctime(), and ctime() */ 22 23 struct timespec { 24 time_t tv_sec; /* seconds */ 25 long tv_nsec; /* and nanoseconds */ 26 }; 27 28 struct itimerspec { 29 struct timespec it_interval; 30 struct timespec it_value; 31 }; 32 33 struct tm { 34 int tm_sec; 35 int tm_min; 36 int tm_hour; 37 int tm_mday; /* day of month (1 to 31) */ 38 int tm_mon; /* months since January (0 to 11) */ 39 int tm_year; /* years since 1900 */ 40 int tm_wday; /* days since Sunday (0 to 6, Sunday = 0, ...) */ 41 int tm_yday; /* days since January 1 (0 to 365) */ 42 int tm_isdst; /* daylight savings time (0 == no, >0 == yes, <0 == has to be calculated */ 43 int tm_gmtoff; /* timezone offset to GMT */ 44 char *tm_zone; /* timezone name */ 45 }; 46 47 48 /* special timezone support */ 49 extern char *tzname[2]; 50 extern int daylight; 51 extern long timezone; 52 53 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 58 extern clock_t clock(void); 59 extern double difftime(time_t time1, time_t time2); 60 extern time_t mktime(struct tm *tm); 61 extern time_t time(time_t *timer); 62 extern char *asctime(const struct tm *tm); 63 extern char *asctime_r(const struct tm *timep, char *buffer); 64 extern char *ctime(const time_t *timer); 65 extern char *ctime_r(const time_t *timer, char *buffer); 66 extern struct tm *gmtime(const time_t *timer); 67 extern struct tm *gmtime_r(const time_t *timer, struct tm *tm); 68 extern struct tm *localtime(const time_t *timer); 69 extern struct tm *localtime_r(const time_t *timer, struct tm *tm); 70 extern int nanosleep(const struct timespec *, struct timespec *); 71 extern size_t strftime(char *buffer, size_t maxSize, const char *format, 72 const struct tm *tm); 73 extern char *strptime(const char *buf, const char *format, struct tm *tm); 74 75 /* special timezone support */ 76 extern void tzset(void); 77 78 /* non-POSIX */ 79 extern int stime(const time_t *t); 80 81 #ifdef __cplusplus 82 } 83 #endif 84 85 86 #endif /* _TIME_H_ */ 87