module Time::EpochMillisConverter
Overview
Converter to be used with Benconding::Field
annotation
to serialize a Time
instance as the number of milliseconds
since the unix epoch. See Time#to_unix_ms
.
require "bencoding"
class Timestamp
include Bencoding::Serializable
@[Bencoding::Field(converter: Time::EpochMillisConverter)]
property value : Time
end
timestamp = Timestamp.bdecode("i1459860483856e")
timestamp.value # => 2016-04-05 12:48:03.856 UTC
timestamp.bencode # => "i1459860483856e"