Skip to content

Instantly share code, notes, and snippets.

@RX14

RX14/foo.cr Secret

Created July 11, 2017 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RX14/e79134d1d9964334d6c111e9a5193c90 to your computer and use it in GitHub Desktop.
Save RX14/e79134d1d9964334d6c111e9a5193c90 to your computer and use it in GitHub Desktop.
private def to_timeval(time : Time::Span)
t = uninitialized LibC::Timeval
seconds, remainder_ticks = time.ticks.divmod(Time::Span::TicksPerSecond)
t.tv_sec = typeof(t.tv_sec).new(seconds)
t.tv_usec = typeof(t.tv_usec).new(remainder_ticks / Time::Span::TicksPerMicrosecond)
t
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment