struct Time::Span

Overview

Time::Span represents one period of time.

A Time::Span initializes with the specified period. Different numbers of arguments generate a Time::Span in different length. Check all #new methods for details.

Time::Span.new(nanoseconds: 10_000)                           # => 00:00:00.000010000
Time::Span.new(hours: 10, minutes: 10, seconds: 10)           # => 10:10:10
Time::Span.new(days: 10, hours: 10, minutes: 10, seconds: 10) # => 10.10:10:10

Calculation between Time also returns a Time::Span.

span = Time.utc(2015, 10, 10) - Time.utc(2015, 9, 10)
span       # => 30.00:00:00
span.class # => Time::Span

Inspection:

span = Time::Span.new(hours: 20, minutes: 10, seconds: 10)
span.hours   # => 20
span.minutes # => 10
span.seconds # => 10

Calculation:

a = Time::Span.new(hours: 20, minutes: 10, seconds: 10)
b = Time::Span.new(hours: 10, minutes: 10, seconds: 10)
c = a - b # => 10:00:00
c.hours   # => 10

Included Modules

Defined in:

ssz/codec.cr

Class Method Summary

Instance Method Summary

Instance methods inherited from class Object

ssz_basic? : Bool ssz_basic?, ssz_encode(io : IO)
ssz_encode : Bytes
ssz_encode
, ssz_fixed? : Bool ssz_fixed?, ssz_size : Int32 ssz_size, ssz_variable? : Bool ssz_variable?

Class methods inherited from class Object

ssz_basic? : Bool ssz_basic?, ssz_decode(io : IO, size : Int32 = 0)
ssz_decode(bytes : Bytes)
ssz_decode
, ssz_fixed? : Bool ssz_fixed?, ssz_variable? : Bool ssz_variable?

Class Method Detail

def self.ssz_basic? : Bool #

[View source]
def self.ssz_decode(io : IO, size : Int32) #

[View source]
def self.ssz_decode(bytes : Bytes) #

[View source]
def self.ssz_fixed? : Bool #

[View source]
def self.ssz_variable? : Bool #

[View source]

Instance Method Detail

def ssz_basic? : Bool #

[View source]
def ssz_encode(io : IO) #

[View source]
def ssz_encode : Bytes #

[View source]
def ssz_fixed? : Bool #

[View source]
def ssz_size : Int32 #

[View source]
def ssz_variable? : Bool #

[View source]