1module time
2
3// solaris_now returns the local time with high precision for most os:es
4// this should be implemented properly with support for leap seconds.
5// It uses the realtime clock to get and converts it to local time
6[inline]
7fn solaris_now() Time {
8
9	// get the high precision time as UTC realtime clock
10	// and use the nanoseconds part
11	mut ts := C.timespec{}
12	C.clock_gettime(C.CLOCK_REALTIME, &ts)
13
14	loc_tm := C.tm{}
15	C.localtime_r(&ts.tv_sec, &loc_tm)
16
17	return convert_ctime(loc_tm, int(ts.tv_nsec/1000))
18}
19
20[inline]
21fn solaris_utc() Time {
22	// get the high precision time as UTC realtime clock
23	// and use the nanoseconds part
24	mut ts := C.timespec{}
25	C.clock_gettime(C.CLOCK_REALTIME, &ts)
26
27	return unix2(int(ts.tv_sec), int(ts.tv_nsec/1000))
28}
29
30// dummy to compile with all compilers
31pub fn linux_now() Time {
32	return Time{}
33}
34
35// dummy to compile with all compilers
36pub fn darwin_now() Time {
37	return Time{}
38}
39
40// dummy to compile with all compilers
41pub fn linux_utc() Time {
42	return Time{}
43}
44
45// dummy to compile with all compilers
46pub fn darwin_utc() Time {
47	return Time{}
48}