xref: /haiku/headers/private/fs_shell/fssh_time.h (revision e81a954787e50e56a7f06f72705b7859b6ab06d1)
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 /* special timezone support */
54 extern char *fssh_tzname[2];
55 extern int 	fssh_daylight;
56 extern long	fssh_timezone;
57 
58 
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
62 
63 extern fssh_clock_t		fssh_clock(void);
64 extern double			fssh_difftime(fssh_time_t time1, fssh_time_t time2);
65 extern fssh_time_t		fssh_mktime(struct fssh_tm *tm);
66 extern fssh_time_t		fssh_time(fssh_time_t *timer);
67 extern char				*fssh_asctime(const struct fssh_tm *tm);
68 extern char				*fssh_asctime_r(const struct fssh_tm *timep,
69 								char *buffer);
70 extern 	char			*fssh_ctime(const fssh_time_t *timer);
71 extern char				*fssh_ctime_r(const fssh_time_t *timer, char *buffer);
72 extern struct fssh_tm	*fssh_gmtime(const fssh_time_t *timer);
73 extern struct fssh_tm	*fssh_gmtime_r(const fssh_time_t *timer,
74 								struct fssh_tm *tm);
75 extern struct fssh_tm	*fssh_localtime(const fssh_time_t *timer);
76 extern struct fssh_tm	*fssh_localtime_r(const fssh_time_t *timer,
77 								struct fssh_tm *tm);
78 extern fssh_size_t		fssh_strftime(char *buffer, fssh_size_t maxSize,
79 								const char *format, const struct fssh_tm *tm);
80 extern char 			*fssh_strptime(const char *buf, const char *format,
81 								struct fssh_tm *tm);
82 
83 /* special timezone support */
84 extern void fssh_tzset(void);
85 extern int	fssh_stime(const fssh_time_t *t);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif	/* _FSSH_TIME_H_ */
92