Skip to content

Commit

Permalink
Release v1.0.0
Browse files Browse the repository at this point in the history
This package has been stable for several years with no bug reports in that
time. It is also pretty much feature complete. I am therefore updating the
version to 1.0.0.

Because this is a major release, the previously deprecated TimeV functions
has been removed.
  • Loading branch information
beevik committed May 7, 2023
1 parent af4a82b commit ad2604d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
14 changes: 14 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
Release v1.0.0
==============

This package has been stable for several years with no bug reports in that
time. It is also pretty much feature complete. I am therefore updating the
version to 1.0.0.

Because this is a major release, all previously deprecated code has been
removed from the package.

**Breaking changes**

* Removed the `TimeV` function. Use `Time` or `QueryWithOptions` instead.

Release v0.3.2
==============

Expand Down
24 changes: 5 additions & 19 deletions ntp.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ func (m *msg) setLeap(li LeapIndicator) {
m.LiVnMode = (m.LiVnMode & 0x3f) | uint8(li)<<6
}

// getVersion returns the version value in the message.
func (m *msg) getVersion() int {
return int((m.LiVnMode >> 3) & 0x07)
}

// getMode returns the mode value in the message.
func (m *msg) getMode() mode {
return mode(m.LiVnMode & 0x07)
Expand Down Expand Up @@ -302,17 +297,15 @@ func QueryWithOptions(host string, opt QueryOptions) (*Response, error) {
return parseTime(m, now), nil
}

// TimeV returns the current time using information from a remote NTP server.
// On error, it returns the local system time. The version may be 2, 3, or 4.
//
// Deprecated: TimeV is deprecated. Use QueryWithOptions instead.
func TimeV(host string, version int) (time.Time, error) {
m, recvTime, err := getTime(host, QueryOptions{Version: version})
// Time returns the current time using information from a remote NTP server.
// It uses version 4 of the NTP protocol. On error, it returns the local
// system time.
func Time(host string) (time.Time, error) {
r, err := Query(host)
if err != nil {
return time.Now(), err
}

r := parseTime(m, recvTime)
err = r.Validate()
if err != nil {
return time.Now(), err
Expand All @@ -322,13 +315,6 @@ func TimeV(host string, version int) (time.Time, error) {
return time.Now().Add(r.ClockOffset), nil
}

// Time returns the current time using information from a remote NTP server.
// It uses version 4 of the NTP protocol. On error, it returns the local
// system time.
func Time(host string) (time.Time, error) {
return TimeV(host, defaultNtpVersion)
}

// getTime performs the NTP server query and returns the response message
// along with the local system time it was received.
func getTime(host string, opt QueryOptions) (*msg, ntpTime, error) {
Expand Down

0 comments on commit ad2604d

Please sign in to comment.