struct Time::Span
Overview
Time::Span
represents one period of time.
A Time::Span
initializes with the specified period.
Different numbers of arguments generates a Time::Span
in different length.
Check all #new
methods for details.
Time::Span.new(10000) # => 0:0:0.010000
Time::Span.new(10, 10, 10) # => 10:10:10
Time::Span.new(10, 10, 10, 10) # => 10.10:10:10
Calculation between Time
also returns a Time::Span
.
span = Time.new(2015, 10, 10) - Time.new(2015, 9, 10)
span # => 30.00:00:00
span.class # => Time::Span
Inspection:
span = Time::Span.new(20, 10, 10)
span.hours # => 20
span.minutes # => 10
span.seconds # => 10
Calculation:
a = Time::Span.new(20, 10, 10)
b = Time::Span.new(10, 10, 10)
c = a - b # => 10:00:00
c.hours # => 10
Included Modules
Defined in:
time/span.crConstant Summary
-
MaxValue =
new(Int64::MAX)
-
MinValue =
new(Int64::MIN)
-
TicksPerDay =
TicksPerHour * 24
-
TicksPerHour =
TicksPerMinute * 60
-
TicksPerMillisecond =
10000_i64
-
TicksPerMinute =
TicksPerSecond * 60
-
TicksPerSecond =
TicksPerMillisecond * 1000
-
Zero =
new(0)
Class Method Summary
- .from(value, tick_multiplicator)
- .new(days, hours, minutes, seconds, milliseconds)
- .new(days, hours, minutes, seconds)
- .new(hours, minutes, seconds)
- .new(ticks)
Instance Method Summary
- #*(number : Number)
- #+
- #+(other : self)
- #-(other : self)
- #-
- #/(number : Number)
- #<=>(other : self)
- #abs
- #ago
- #days
- #duration
- #from_now
- #hours
- #inspect(io : IO)
- #milliseconds
- #minutes
- #seconds
- #ticks : Int64
- #to_f
- #to_i
- #total_days
- #total_hours
- #total_milliseconds
- #total_minutes
- #total_seconds
- #total_weeks
Instance methods inherited from module Comparable(T)
<(other : T)
<,
<=(other : T)
<=,
<=>(other : T)
<=>,
==(other : T)
==,
>(other : T)
>,
>=(other : T)
>=
Instance methods inherited from struct Struct
==(other : self) : Bool
==,
hash : Int32
hash,
inspect(io : IO) : Nil
inspect,
to_s(io)
to_s
Instance methods inherited from struct Value
==(other)
==
Instance methods inherited from class Object
!=(other)
!=,
!~(other)
!~,
==(other)
==,
===(other)===(other : YAML::Any)
===(other : JSON::Any) ===, =~(other) =~, class class, clone clone, crystal_type_id crystal_type_id, dup dup, hash hash, inspect
inspect(io : IO) inspect, itself itself, not_nil! not_nil!, tap(&block) tap, to_json to_json, to_pretty_json(io : IO)
to_pretty_json to_pretty_json, to_s
to_s(io : IO) to_s, to_yaml(io : IO)
to_yaml to_yaml, try(&block) try