module Time::EpochConverter

Overview

Converter to be used with NASON::Serializable and YAML::Serializable to serialize a Time instance as the number of seconds since the unix epoch. See Time#to_unix.

require "nason"

class Person
  include NASON::Serializable

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

person = Person.from_nason(%({"birth_date": 1459859781}))
person.birth_date # => 2016-04-05 12:36:21 UTC
person.to_nason   # => %({"birth_date":1459859781})

Defined in:

nason/from_json.cr
nason/to_json.cr

Class Method Summary

Class Method Detail

def self.from_nason(value : NASON::PullParser) : Time #

[View source]
def self.to_nason(value : Time, json : NASON::Builder) : Nil #

[View source]