xref: /haiku/headers/private/fs_shell/fssh_time.h (revision 7868a011b865447e04d6cdc0db21d3a18ab5ab12)
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__)
13 typedef int32_t fssh_time_t;
14 #else
15 typedef int64_t fssh_time_t;
16 #endif
17 
18 typedef int32_t fssh_clock_t;
19 typedef int32_t fssh_suseconds_t;
20 typedef 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 
28 struct fssh_timespec {
29 	fssh_time_t	tv_sec;		/* seconds */
30 	long		tv_nsec;	/* and nanoseconds */
31 };
32 
33 struct fssh_itimerspec {
34 	struct fssh_timespec it_interval;
35 	struct fssh_timespec it_value;
36 };
37 
38 struct 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
54 extern "C" {
55 #endif
56 
57 /* special timezone support */
58 extern char *fssh_tzname[2];
59 extern int 	fssh_daylight;
60 extern long	fssh_timezone;
61 
62 extern fssh_clock_t		fssh_clock(void);
63 extern double			fssh_difftime(fssh_time_t time1, fssh_time_t time2);
64 extern fssh_time_t		fssh_mktime(struct fssh_tm *tm);
65 extern fssh_time_t		fssh_time(fssh_time_t *timer);
66 extern char				*fssh_asctime(const struct fssh_tm *tm);
67 extern char				*fssh_asctime_r(const struct fssh_tm *timep,
68 								char *buffer);
69 extern 	char			*fssh_ctime(const fssh_time_t *timer);
70 extern char				*fssh_ctime_r(const fssh_time_t *timer, char *buffer);
71 extern struct fssh_tm	*fssh_gmtime(const fssh_time_t *timer);
72 extern struct fssh_tm	*fssh_gmtime_r(const fssh_time_t *timer,
73 								struct fssh_tm *tm);
74 extern struct fssh_tm	*fssh_localtime(const fssh_time_t *timer);
75 extern struct fssh_tm	*fssh_localtime_r(const fssh_time_t *timer,
76 								struct fssh_tm *tm);
77 extern fssh_size_t		fssh_strftime(char *buffer, fssh_size_t maxSize,
78 								const char *format, const struct fssh_tm *tm);
79 extern char 			*fssh_strptime(const char *buf, const char *format,
80 								struct fssh_tm *tm);
81 
82 /* special timezone support */
83 extern void fssh_tzset(void);
84 extern int	fssh_stime(const fssh_time_t *t);
85 
86 #ifdef __cplusplus
87 }
88 #endif
89 
90 #endif	/* _FSSH_TIME_H_ */
91