mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
unix: use Time{spec,val}.Nano in Time{spec,val}ToNsec
Follow what CL 188397 did in package syscall: Call the Nano methods of Timespec and Timeval in TimespecToNsec and TimevalToNsec respectively, instead of duplicating the implementation. Change-Id: I50f1958c0f7bca92fc4990684f1de9c148ae5859 Reviewed-on: https://go-review.googlesource.com/c/sys/+/277253 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
committed by
Tobias Klauser
parent
8c39875709
commit
aec9a39092
@@ -9,7 +9,7 @@ package unix
|
||||
import "time"
|
||||
|
||||
// TimespecToNSec returns the time stored in ts as nanoseconds.
|
||||
func TimespecToNsec(ts Timespec) int64 { return int64(ts.Sec)*1e9 + int64(ts.Nsec) }
|
||||
func TimespecToNsec(ts Timespec) int64 { return ts.Nano() }
|
||||
|
||||
// NsecToTimespec converts a number of nanoseconds into a Timespec.
|
||||
func NsecToTimespec(nsec int64) Timespec {
|
||||
@@ -41,7 +41,7 @@ func TimeToTimespec(t time.Time) (Timespec, error) {
|
||||
}
|
||||
|
||||
// TimevalToNsec returns the time stored in tv as nanoseconds.
|
||||
func TimevalToNsec(tv Timeval) int64 { return int64(tv.Sec)*1e9 + int64(tv.Usec)*1e3 }
|
||||
func TimevalToNsec(tv Timeval) int64 { return tv.Nano() }
|
||||
|
||||
// NsecToTimeval converts a number of nanoseconds into a Timeval.
|
||||
func NsecToTimeval(nsec int64) Timeval {
|
||||
|
||||
Reference in New Issue
Block a user