mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-06 14:33:13 -04:00
date test
This commit is contained in:
@ -6,7 +6,7 @@ import (
|
||||
|
||||
type Date [8]byte
|
||||
|
||||
func GoDate(date Date) time.Time {
|
||||
func (date Date) Time() time.Time {
|
||||
seconds := Integer(date[:])
|
||||
return time.Unix(0, int64(seconds*1000000))
|
||||
}
|
||||
|
11
lib/common/date_test.go
Normal file
11
lib/common/date_test.go
Normal file
@ -0,0 +1,11 @@
|
||||
package common
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestTimeFromMiliseconds(t *testing.T) {
|
||||
next_day := Date{0x00, 0x00, 0x00, 0x00, 0x05, 0x26, 0x5c, 0x00}
|
||||
go_time := next_day.Time()
|
||||
if go_time.Unix() != 86400 {
|
||||
t.Fatal("Date.Time() did not parse time in milliseconds")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user