v

Зеркало из https://github.com/vlang/v
Форк
0
/
time_solaris.c.v 
32 строки · 905.0 Байт
1
module 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
fn solaris_now() Time {
7
	// get the high precision time as UTC realtime clock
8
	// and use the nanoseconds part
9
	mut ts := C.timespec{}
10
	C.clock_gettime(C.CLOCK_REALTIME, &ts)
11
	loc_tm := C.tm{}
12
	C.localtime_r(voidptr(&ts.tv_sec), &loc_tm)
13
	return convert_ctime(loc_tm, int(ts.tv_nsec))
14
}
15

16
fn solaris_utc() Time {
17
	// get the high precision time as UTC realtime clock
18
	// and use the nanoseconds part
19
	mut ts := C.timespec{}
20
	C.clock_gettime(C.CLOCK_REALTIME, &ts)
21
	return unix_nanosecond(i64(ts.tv_sec), int(ts.tv_nsec))
22
}
23

24
// dummy to compile with all compilers
25
fn darwin_now() Time {
26
	return Time{}
27
}
28

29
// dummy to compile with all compilers
30
fn darwin_utc() Time {
31
	return Time{}
32
}
33

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.