You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently we have exposed the syscalls and types related to PTP (IEEE 1588) on Linux in the unix package.
Amongs those is a struct representing time in PTP calls, unix.PtpClockTime. Semantically it is very similar to Unix time, differing in underlying type for the nanoseconds field and having a placeholder for future extentions.
The proposal is to add the convenience methods to carry conversion between unix.PtpClockTime and time.Time:
This shall allow to use the maths of the standard time package while avoiding
the boilerplate: write ptpt.Time() instead of time.Unix(ptpt.Sec, int64(ptpt.Nsec)),
and unix.TimeToPtpClockTime(t) instead of unix.PtpClockTime{Sec: t.Unix(), Nsec: uint32(t.Nanosecond())}.
As an example of what the boilerplate looks like in real-world code, please see facebook/time#418.
seankhliao
changed the title
proposal: golang.org/x/sys/unix: add methods to covert between time.Time and unix.PtpClockTime on Linux
proposal: x/sys/unix: add methods to covert between time.Time and unix.PtpClockTime on Linux
Oct 24, 2024
Summary:
Pull Request resolved: #418
Avoid the non-upstreamed unix.PtpClockTime.Time().
The related [golang/go#70032](golang/go#70032) is still pending decision. In case of positive outcome we can unland this.
Reviewed By: leoleovich
Differential Revision: D64901381
fbshipit-source-id: b06c389dff7f0720391bc8dac81e6a346a111a58
Proposal Details
Recently we have exposed the syscalls and types related to PTP (IEEE 1588) on Linux in the
unix
package.Amongs those is a struct representing time in PTP calls,
unix.PtpClockTime
. Semantically it is very similar to Unix time, differing in underlying type for the nanoseconds field and having a placeholder for future extentions.The proposal is to add the convenience methods to carry conversion between unix.PtpClockTime and time.Time:
This shall allow to use the maths of the standard time package while avoiding
the boilerplate: write
ptpt.Time()
instead oftime.Unix(ptpt.Sec, int64(ptpt.Nsec))
,and
unix.TimeToPtpClockTime(t)
instead ofunix.PtpClockTime{Sec: t.Unix(), Nsec: uint32(t.Nanosecond())}
.As an example of what the boilerplate looks like in real-world code, please see facebook/time#418.
golang/sys#230 implements the proposal.
Thank you for consideration.
The text was updated successfully, but these errors were encountered: