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
12typedef int32_t fssh_clock_t;
13typedef int32_t fssh_time_t;
14typedef int32_t fssh_suseconds_t;
15typedef 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
23struct fssh_timespec {
24	fssh_time_t	tv_sec;		/* seconds */
25	long		tv_nsec;	/* and nanoseconds */
26};
27
28struct fssh_itimerspec {
29	struct fssh_timespec it_interval;
30	struct fssh_timespec it_value;
31};
32
33struct 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 */
49extern char *fssh_tzname[2];
50extern int 	fssh_daylight;
51extern long	fssh_timezone;
52
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58extern fssh_clock_t		fssh_clock(void);
59extern double			fssh_difftime(fssh_time_t time1, fssh_time_t time2);
60extern fssh_time_t		fssh_mktime(struct fssh_tm *tm);
61extern fssh_time_t		fssh_time(fssh_time_t *timer);
62extern char				*fssh_asctime(const struct fssh_tm *tm);
63extern char				*fssh_asctime_r(const struct fssh_tm *timep,
64								char *buffer);
65extern 	char			*fssh_ctime(const fssh_time_t *timer);
66extern char				*fssh_ctime_r(const fssh_time_t *timer, char *buffer);
67extern struct fssh_tm	*fssh_gmtime(const fssh_time_t *timer);
68extern struct fssh_tm	*fssh_gmtime_r(const fssh_time_t *timer,
69								struct fssh_tm *tm);
70extern struct fssh_tm	*fssh_localtime(const fssh_time_t *timer);
71extern struct fssh_tm	*fssh_localtime_r(const fssh_time_t *timer,
72								struct fssh_tm *tm);
73extern fssh_size_t		fssh_strftime(char *buffer, fssh_size_t maxSize,
74								const char *format, const struct fssh_tm *tm);
75extern char 			*fssh_strptime(const char *buf, const char *format,
76								struct fssh_tm *tm);
77
78/* special timezone support */
79extern void fssh_tzset(void);
80extern int	fssh_stime(const fssh_time_t *t);
81
82#ifdef __cplusplus
83}
84#endif
85
86#endif	/* _FSSH_TIME_H_ */
87