module Time::EpochConverter

Overview

Converter to be used with Benconding::Field annotation to serialize a Time instance as the number of seconds since the unix epoch. See Time#to_unix.

require "bencoding"

class Person
  include Bencoding::Serializable

  @[Bencoding::Field(converter: Time::EpochConverter)]
  property birth_date : Time
end

person = Person.bdecode("i1459859781e")
person.birth_date # => 2016-04-05 12:36:21 UTC
person.bencode    # => "i1459859781e"

Defined in:

bencoding/bencode.cr

Class Method Summary

Class Method Detail

def self.bencode(value : Time, builder : Bencoding::Builder) #

[View source]