xref: /haiku/headers/private/kernel/real_time_clock.h (revision d3d8b26997fac34a84981e6d2b649521de2cc45a)
1 /*
2  * Copyright 2006, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3  * Copyright 2003, Jeff Ward, jeff@r2d2.stcloudstate.edu. All rights reserved.
4  *
5  * Distributed under the terms of the MIT License.
6  */
7 #ifndef _KERNEL_REAL_TIME_CLOCK_H
8 #define _KERNEL_REAL_TIME_CLOCK_H
9 
10 
11 #include <KernelExport.h>
12 
13 #include <time.h>
14 
15 
16 #define RTC_EPOCHE_BASE_YEAR	1970
17 
18 typedef struct rtc_info {
19 	uint32	time;
20 	bool	is_gmt;
21 	int32	tz_minuteswest;
22 	bool	tz_dsttime;
23 } rtc_info;
24 
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 status_t rtc_init(kernel_args *args);
31 bigtime_t rtc_boot_time(void);
32 	// Returns the time at which the system was booted in microseconds since Jan 1, 1970 UTC.
33 
34 status_t get_rtc_info(rtc_info *info);
35 
36 // Both functions use the passed struct tm only partially
37 // (no tm_wday, tm_yday, tm_isdst).
38 uint32 rtc_tm_to_secs(const struct tm *t);
39 void rtc_secs_to_tm(uint32 seconds, struct tm *t);
40 
41 bigtime_t _user_system_time(void);
42 status_t _user_set_real_time_clock(uint32 time);
43 status_t _user_set_timezone(int32 timezoneOffset, bool daylightSavingTime);
44 status_t _user_get_timezone(int32 *_timezoneOffset, bool *_daylightSavingTime);
45 status_t _user_set_tzfilename(const char* filename, size_t length, bool isGMT);
46 status_t _user_get_tzfilename(char *filename, size_t length, bool *_isGMT);
47 
48 #ifdef __cplusplus
49 }
50 #endif
51 
52 #endif /* _KERNEL_REAL_TIME_CLOCK_H */
53