1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

time: v fmt (#7160)

This commit is contained in:
Takahiro Yaota
2020-12-06 23:19:39 +09:00
committed by GitHub
parent 43ff93c25f
commit 0c50f0c9dc
14 changed files with 147 additions and 212 deletions

View File

@ -5,16 +5,13 @@ module time
// It uses the realtime clock to get and converts it to local time
[inline]
fn solaris_now() Time {
// get the high precision time as UTC realtime clock
// and use the nanoseconds part
mut ts := C.timespec{}
C.clock_gettime(C.CLOCK_REALTIME, &ts)
loc_tm := C.tm{}
C.localtime_r(&ts.tv_sec, &loc_tm)
return convert_ctime(loc_tm, int(ts.tv_nsec/1000))
return convert_ctime(loc_tm, int(ts.tv_nsec / 1000))
}
[inline]
@ -23,8 +20,7 @@ fn solaris_utc() Time {
// and use the nanoseconds part
mut ts := C.timespec{}
C.clock_gettime(C.CLOCK_REALTIME, &ts)
return unix2(int(ts.tv_sec), int(ts.tv_nsec/1000))
return unix2(int(ts.tv_sec), int(ts.tv_nsec / 1000))
}
// dummy to compile with all compilers
@ -45,4 +41,4 @@ pub fn linux_utc() Time {
// dummy to compile with all compilers
pub fn darwin_utc() Time {
return Time{}
}
}