Source File
timestruct.go
Belonging Package
syscall
// Copyright 2016 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// +build aix darwin dragonfly freebsd js,wasm linux netbsd openbsd solarispackage syscall// TimespecToNSec returns the time stored in ts as nanoseconds.func ( Timespec) int64 { return .Nano() }// NsecToTimespec converts a number of nanoseconds into a Timespec.func ( int64) Timespec {:= / 1e9= % 1e9if < 0 {+= 1e9--}return setTimespec(, )}// TimevalToNsec returns the time stored in tv as nanoseconds.func ( Timeval) int64 { return .Nano() }// NsecToTimeval converts a number of nanoseconds into a Timeval.func ( int64) Timeval {+= 999 // round up to microsecond:= % 1e9 / 1e3:= / 1e9if < 0 {+= 1e6--}return setTimeval(, )}