a5ebab63e7
* New Providers added and updated vendoring for go-discover * Vendor.json formatted using make vendorfmt * Docs/Agent/auto-join: Added documentation for the new providers introduced in this PR * Updated the golang.org/x/sys/unix in the vendor directory * Agent: TestGoDiscoverRegistration updated to reflect the addition of new providers * Deleted terraform.tfstate from vendor. * Deleted terraform.tfstate.backup Deleted terraform state file artifacts from unknown runs. * Updated x/sys/windows vendor for Windows binary compilation
36 lines
834 B
Go
36 lines
834 B
Go
package packngo
|
|
|
|
import (
|
|
"strconv"
|
|
"time"
|
|
)
|
|
|
|
// Timestamp represents a time that can be unmarshalled from a JSON string
|
|
// formatted as either an RFC3339 or Unix timestamp. All
|
|
// exported methods of time.Time can be called on Timestamp.
|
|
type Timestamp struct {
|
|
time.Time
|
|
}
|
|
|
|
func (t Timestamp) String() string {
|
|
return t.Time.String()
|
|
}
|
|
|
|
// UnmarshalJSON implements the json.Unmarshaler interface.
|
|
// Time is expected in RFC3339 or Unix format.
|
|
func (t *Timestamp) UnmarshalJSON(data []byte) (err error) {
|
|
str := string(data)
|
|
i, err := strconv.ParseInt(str, 10, 64)
|
|
if err == nil {
|
|
t.Time = time.Unix(i, 0)
|
|
} else {
|
|
t.Time, err = time.Parse(`"`+time.RFC3339+`"`, str)
|
|
}
|
|
return
|
|
}
|
|
|
|
// Equal reports whether t and u are equal based on time.Equal
|
|
func (t Timestamp) Equal(u Timestamp) bool {
|
|
return t.Time.Equal(u.Time)
|
|
}
|