Source file
src/syscall/timestruct.go
1
2
3
4
5
6
7 package syscall
8
9
10 func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
11
12
13 func NsecToTimespec(nsec int64) Timespec {
14 sec := nsec / 1e9
15 nsec = nsec % 1e9
16 if nsec < 0 {
17 nsec += 1e9
18 sec--
19 }
20 return setTimespec(sec, nsec)
21 }
22
23
24 func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
25
26
27 func NsecToTimeval(nsec int64) Timeval {
28 nsec += 999
29 usec := nsec % 1e9 / 1e3
30 sec := nsec / 1e9
31 if usec < 0 {
32 usec += 1e6
33 sec--
34 }
35 return setTimeval(sec, usec)
36 }
37
View as plain text