1 /* 2 * Copyright 2005-2009, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _FSSH_TIME_H_ 6 #define _FSSH_TIME_H_ 7 8 9 #include "fssh_defs.h" 10 11 12 typedef int32_t fssh_clock_t; 13 typedef int32_t fssh_time_t; 14 typedef int32_t fssh_suseconds_t; 15 typedef uint32_t fssh_useconds_t; 16 17 #define FSSH_CLOCKS_PER_SEC 1000 18 #define FSSH_CLK_TCK FSSH_CLOCKS_PER_SEC 19 20 #define FSSH_MAX_TIMESTR 70 21 /* maximum length of a string returned by asctime(), and ctime() */ 22 23 struct fssh_timespec { 24 fssh_time_t tv_sec; /* seconds */ 25 long tv_nsec; /* and nanoseconds */ 26 }; 27 28 struct fssh_itimerspec { 29 struct fssh_timespec it_interval; 30 struct fssh_timespec it_value; 31 }; 32 33 struct fssh_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 *fssh_tzname[2]; 50 extern int fssh_daylight; 51 extern long fssh_timezone; 52 53 54 #ifdef __cplusplus 55 extern "C" { 56 #endif 57 58 extern fssh_clock_t fssh_clock(void); 59 extern double fssh_difftime(fssh_time_t time1, fssh_time_t time2); 60 extern fssh_time_t fssh_mktime(struct fssh_tm *tm); 61 extern fssh_time_t fssh_time(fssh_time_t *timer); 62 extern char *fssh_asctime(const struct fssh_tm *tm); 63 extern char *fssh_asctime_r(const struct fssh_tm *timep, 64 char *buffer); 65 extern char *fssh_ctime(const fssh_time_t *timer); 66 extern char *fssh_ctime_r(const fssh_time_t *timer, char *buffer); 67 extern struct fssh_tm *fssh_gmtime(const fssh_time_t *timer); 68 extern struct fssh_tm *fssh_gmtime_r(const fssh_time_t *timer, 69 struct fssh_tm *tm); 70 extern struct fssh_tm *fssh_localtime(const fssh_time_t *timer); 71 extern struct fssh_tm *fssh_localtime_r(const fssh_time_t *timer, 72 struct fssh_tm *tm); 73 extern fssh_size_t fssh_strftime(char *buffer, fssh_size_t maxSize, 74 const char *format, const struct fssh_tm *tm); 75 extern char *fssh_strptime(const char *buf, const char *format, 76 struct fssh_tm *tm); 77 78 /* special timezone support */ 79 extern void fssh_tzset(void); 80 extern int fssh_stime(const fssh_time_t *t); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 86 #endif /* _FSSH_TIME_H_ */ 87