Files
go-i2p/lib/common/date.go

25 lines
481 B
Go
Raw Normal View History

2016-02-04 00:07:09 -08:00
package common
2016-02-14 23:10:37 -08:00
/*
I2P Date
2016-06-16 23:17:21 -07:00
https://geti2p.net/spec/common-structures#date
2016-02-14 23:10:37 -08:00
Accurate for version 0.9.24
*/
2016-02-04 00:07:09 -08:00
import (
"time"
)
type Date [8]byte
2016-02-06 01:42:47 -08:00
//
2016-02-14 22:40:29 -08:00
// Time takes the value stored in date as an 8 byte big-endian integer representing the
// number of milliseconds since the beginning of unix time and converts it to a Go time.Time
2016-02-06 01:42:47 -08:00
// struct.
//
2016-02-14 22:40:29 -08:00
func (date Date) Time() (date_time time.Time) {
2016-02-04 00:54:51 -08:00
seconds := Integer(date[:])
2016-02-14 22:40:29 -08:00
date_time = time.Unix(0, int64(seconds*1000000))
return
2016-02-04 00:07:09 -08:00
}