diff options
author | dsp <dsp@2f30.org> | 2015-08-27 12:12:15 -0600 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-08-28 05:32:32 +0900 |
commit | f1ee03afe3b7bfd49e3f238b08031d2c35c2395f (patch) | |
tree | 2c1116fbfab9dc1837b3ab8e7f5d9d13f123fb7a /packet/mrt.go | |
parent | 8ef1f381b07d04a38597f1fd5587cc1d377433cf (diff) |
mrt: add helper function for timestamp
Commiting helper function on MRTHeader to return a golang time.Time
from the timestamp. Also commiting the relevant test function.
Diffstat (limited to 'packet/mrt.go')
-rw-r--r-- | packet/mrt.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/packet/mrt.go b/packet/mrt.go index 369e8063..b259be7f 100644 --- a/packet/mrt.go +++ b/packet/mrt.go @@ -21,6 +21,7 @@ import ( "fmt" "math" "net" + "time" ) const ( @@ -139,6 +140,11 @@ func NewMRTHeader(timestamp uint32, t MRTType, subtype MRTSubTyper, l uint32) (* }, nil } +func (h *MRTHeader) GetTime() time.Time { + t := int64(h.Timestamp) + return time.Unix(t, 0) +} + type MRTMessage struct { Header MRTHeader Body Body |