Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NTPTimeStamp type #1315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add NTPTimeStamp type #1315

wants to merge 1 commit into from

Conversation

@phibos phibos marked this pull request as draft December 13, 2024 11:01
@phibos phibos marked this pull request as ready for review December 13, 2024 11:19
func parseNtpTimestamp(pdu *gosnmp.SnmpPDU) (float64, error) {
var data []byte = pdu.Value.([]byte)

// 2208988800 is the Unix Epoch in NTP Seconds (1970 - 1900)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should include a hint that the returned data is "Seconds and Fractions since 01.01.1900" as the ntp era starts on jan 1st 1900 whereas unix epoch starts 70y later (so the 2208988800 is basically the offset between those two eras)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added a comment with additional information, rebased against current main branch and pushed the changes.

Feel free to have a look.

Parse the ntp timestamp and convert it to an unix timestamp

Signed-off-by: PhiBo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants