You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
574 B

package wire
import (
"io"
"time"
. "github.com/tendermint/tendermint/common"
)
/*
Writes nanoseconds since epoch but with millisecond precision.
This is to ease compatibility with Javascript etc.
*/
func WriteTime(t time.Time, w io.Writer, n *int64, err *error) {
nanosecs := t.UnixNano()
millisecs := nanosecs / 1000000
WriteInt64(millisecs*1000000, w, n, err)
}
func ReadTime(r io.Reader, n *int64, err *error) time.Time {
t := ReadInt64(r, n, err)
if t%1000000 != 0 {
PanicSanity("Time cannot have sub-millisecond precision")
}
return time.Unix(0, t)
}