Browse Source

unix: document and move Time{spec,val} methods

Add godoc comments for Time{spec,val} methods Unix and Nano.
Also move them to timestruct.go to the other Time{spec,val} related
functionality.

Change-Id: I3b18c5d1bfb235ea4fea25a18fc34b85c21bb365
Reviewed-on: https://go-review.googlesource.com/73871
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Tobias Klauser 8 years ago
parent
commit
5adf374967
2 changed files with 22 additions and 16 deletions
  1. 0 16
      unix/syscall.go
  2. 22 0
      unix/timestruct.go

+ 0 - 16
unix/syscall.go

@@ -49,19 +49,3 @@ func BytePtrFromString(s string) (*byte, error) {
 // Single-word zero for use when we need a valid pointer to 0 bytes.
 // See mkunix.pl.
 var _zero uintptr
-
-func (ts *Timespec) Unix() (sec int64, nsec int64) {
-	return int64(ts.Sec), int64(ts.Nsec)
-}
-
-func (tv *Timeval) Unix() (sec int64, nsec int64) {
-	return int64(tv.Sec), int64(tv.Usec) * 1000
-}
-
-func (ts *Timespec) Nano() int64 {
-	return int64(ts.Sec)*1e9 + int64(ts.Nsec)
-}
-
-func (tv *Timeval) Nano() int64 {
-	return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
-}

+ 22 - 0
unix/timestruct.go

@@ -38,3 +38,25 @@ func NsecToTimeval(nsec int64) Timeval {
 	}
 	return setTimeval(sec, usec)
 }
+
+// Unix returns ts as the number of seconds and nanoseconds elapsed since the
+// Unix epoch.
+func (ts *Timespec) Unix() (sec int64, nsec int64) {
+	return int64(ts.Sec), int64(ts.Nsec)
+}
+
+// Unix returns tv as the number of seconds and nanoseconds elapsed since the
+// Unix epoch.
+func (tv *Timeval) Unix() (sec int64, nsec int64) {
+	return int64(tv.Sec), int64(tv.Usec) * 1000
+}
+
+// Nano returns ts as the number of nanoseconds elapsed since the Unix epoch.
+func (ts *Timespec) Nano() int64 {
+	return int64(ts.Sec)*1e9 + int64(ts.Nsec)
+}
+
+// Nano returns tv as the number of nanoseconds elapsed since the Unix epoch.
+func (tv *Timeval) Nano() int64 {
+	return int64(tv.Sec)*1e9 + int64(tv.Usec)*1000
+}