Esempio n. 1
0
// pnTime converts Go time.Time to Proton millisecond Unix time.
func pnTime(t time.Time) C.pn_timestamp_t {
	secs := t.Unix()
	// Note: sub-second accuracy is not guaraunteed if the Unix time in
	// nanoseconds cannot be represented by an int64 (sometime around year 2260)
	msecs := (t.UnixNano() % int64(time.Second)) / int64(time.Millisecond)
	return C.pn_timestamp_t(secs*1000 + msecs)
}
Esempio n. 2
0
// pnTime converts Go time.Time to Proton millisecond Unix time.
//
// Note: t.isZero() is converted to C.pn_timestamp_t(0) and vice-versa. These
// are used as "not set" sentinel values by the Go and Proton APIs, so it is
// better to conserve the "zeroness" even though they don't represent the same
// time instant.
//
func pnTime(t time.Time) (pnt C.pn_timestamp_t) {
	if !t.IsZero() {
		pnt = C.pn_timestamp_t(t.Unix()*1000 + int64(t.Nanosecond())/int64(time.Millisecond))
	}
	return
}