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#if defined(__i386__) && !defined(__x86_64__) 13typedef int32_t fssh_time_t; 14#else 15typedef int64_t fssh_time_t; 16#endif 17 18typedef int32_t fssh_clock_t; 19typedef int32_t fssh_suseconds_t; 20typedef uint32_t fssh_useconds_t; 21 22#define FSSH_CLOCKS_PER_SEC 1000 23#define FSSH_CLK_TCK FSSH_CLOCKS_PER_SEC 24 25#define FSSH_MAX_TIMESTR 70 26 /* maximum length of a string returned by asctime(), and ctime() */ 27 28struct fssh_timespec { 29 fssh_time_t tv_sec; /* seconds */ 30 long tv_nsec; /* and nanoseconds */ 31}; 32 33struct fssh_itimerspec { 34 struct fssh_timespec it_interval; 35 struct fssh_timespec it_value; 36}; 37 38struct fssh_tm { 39 int tm_sec; 40 int tm_min; 41 int tm_hour; 42 int tm_mday; /* day of month (1 to 31) */ 43 int tm_mon; /* months since January (0 to 11) */ 44 int tm_year; /* years since 1900 */ 45 int tm_wday; /* days since Sunday (0 to 6, Sunday = 0, ...) */ 46 int tm_yday; /* days since January 1 (0 to 365) */ 47 int tm_isdst; /* daylight savings time (0 == no, >0 == yes, <0 == has to be calculated */ 48 int tm_gmtoff; /* timezone offset to GMT */ 49 char *tm_zone; /* timezone name */ 50}; 51 52 53#ifdef __cplusplus 54extern "C" { 55#endif 56 57/* special timezone support */ 58extern char *fssh_tzname[2]; 59extern int fssh_daylight; 60extern long fssh_timezone; 61 62extern fssh_clock_t fssh_clock(void); 63extern double fssh_difftime(fssh_time_t time1, fssh_time_t time2); 64extern fssh_time_t fssh_mktime(struct fssh_tm *tm); 65extern fssh_time_t fssh_time(fssh_time_t *timer); 66extern char *fssh_asctime(const struct fssh_tm *tm); 67extern char *fssh_asctime_r(const struct fssh_tm *timep, 68 char *buffer); 69extern char *fssh_ctime(const fssh_time_t *timer); 70extern char *fssh_ctime_r(const fssh_time_t *timer, char *buffer); 71extern struct fssh_tm *fssh_gmtime(const fssh_time_t *timer); 72extern struct fssh_tm *fssh_gmtime_r(const fssh_time_t *timer, 73 struct fssh_tm *tm); 74extern struct fssh_tm *fssh_localtime(const fssh_time_t *timer); 75extern struct fssh_tm *fssh_localtime_r(const fssh_time_t *timer, 76 struct fssh_tm *tm); 77extern fssh_size_t fssh_strftime(char *buffer, fssh_size_t maxSize, 78 const char *format, const struct fssh_tm *tm); 79extern char *fssh_strptime(const char *buf, const char *format, 80 struct fssh_tm *tm); 81 82/* special timezone support */ 83extern void fssh_tzset(void); 84extern int fssh_stime(const fssh_time_t *t); 85 86#ifdef __cplusplus 87} 88#endif 89 90#endif /* _FSSH_TIME_H_ */ 91