Source File
timestruct.go
Belonging Package
golang.org/x/sys/unix
// Copyright 2017 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 linux netbsd openbsd solarispackage uniximport// TimespecToNsec converts a Timespec value into a number of// nanoseconds since the Unix epoch.func ( Timespec) int64 { return int64(.Sec)*1e9 + int64(.Nsec) }// NsecToTimespec takes a number of nanoseconds since the Unix epoch// and returns the corresponding Timespec value.func ( int64) Timespec {:= / 1e9= % 1e9if < 0 {+= 1e9--}return setTimespec(, )}// TimeToTimespec converts t into a Timespec.// On some 32-bit systems the range of valid Timespec values are smaller// than that of time.Time values. So if t is out of the valid range of// Timespec, it returns a zero Timespec and ERANGE.func ( time.Time) (Timespec, error) {:= .Unix():= int64(.Nanosecond()):= setTimespec(, )// Currently all targets have either int32 or int64 for Timespec.Sec.// If there were a new target with floating point type for it, we have// to consider the rounding error.if int64(.Sec) != {return Timespec{}, ERANGE}return , nil}// TimevalToNsec converts a Timeval value into a number of nanoseconds// since the Unix epoch.func ( Timeval) int64 { return int64(.Sec)*1e9 + int64(.Usec)*1e3 }// NsecToTimeval takes a number of nanoseconds since the Unix epoch// and returns the corresponding Timeval value.func ( int64) Timeval {+= 999 // round up to microsecond:= % 1e9 / 1e3:= / 1e9if < 0 {+= 1e6--}return setTimeval(, )}// Unix returns ts as the number of seconds and nanoseconds elapsed since the// Unix epoch.func ( *Timespec) () ( int64, int64) {return int64(.Sec), int64(.Nsec)}// Unix returns tv as the number of seconds and nanoseconds elapsed since the// Unix epoch.func ( *Timeval) () ( int64, int64) {return int64(.Sec), int64(.Usec) * 1000}// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.func ( *Timespec) () int64 {return int64(.Sec)*1e9 + int64(.Nsec)}// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.func ( *Timeval) () int64 {return int64(.Sec)*1e9 + int64(.Usec)*1000}
The pages are generated with Golds v0.2.8-preview. (GOOS=darwin GOARCH=arm64)