cannon icon indicating copy to clipboard operation
cannon copied to clipboard

Time does not serialize correctly in Crystal .34

Open srcrip opened this issue 5 years ago • 1 comments

I think if you want to make a time with seconds now you now need to do something like this:

crystal

struct Time
  def self.from_cannon_io(io)
    utc(seconds: Cannon.decode(io, Int64), nanoseconds: 0)
  end

  def self.to_cannon_io(io)
    io.write_bytes self
    io
  end
end

Basically I think you need to specify a location now. The simplest way is to use UTC.

There might be others too.

srcrip avatar Jun 07 '20 19:06 srcrip

Opened a PR with what I think to be an ok fix. There should probably be Time's added to the specs if there isnt already though.

srcrip avatar Jun 07 '20 19:06 srcrip