struct

Time

Inherits Steppable < Comparable < Struct < Value < Object

Time cast methods

Constructors

unix(seconds : Int, location = Location::UTC) : Time

Creates a new Time instance that corresponds to the number of seconds elapsed since the Unix epoch (1970-01-01 00:00:00Z).

The time zone is always UTC.

Time.unix(981173106) # => 2001-02-03 04:05:06Z
Source
unix_ms(milliseconds : Int, location = Location::UTC) : Time

Creates a new Time instance that corresponds to the number of milliseconds elapsed since the Unix epoch (1970-01-01 00:00:00Z).

The time zone is always UTC.

time = Time.unix_ms(981173106789) # => 2001-02-03 04:05:06.789Z
time.millisecond                  # => 789
Source

Instance methods

cast(other)
cast?(other)
to_array(value_type : T.class = String) forall T

Returns the Array value represented by given YAML::Any type, else raise a TypeCastError exception.

to_array?(value_type : T.class = String) forall T

Returns the Array value represented by given YAML::Any type, else raise a TypeCastError exception.

to_bool

Returns the Bool value represented by given YAML::Any type, else raise a TypeCastError exception.

to_bool?

Returns the Bool value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float

Returns the Float value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float32

Returns the Float32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float32?

Returns the Float32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float64

Returns the Float64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float64?

Returns the Float64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_float?

Returns the Float value represented by given YAML::Any type, else raise a TypeCastError exception.

to_hash(value_type : T.class = String) forall T

Returns the Hash value represented by given YAML::Any type, else raise a TypeCastError exception.

to_hash?(value_type : T.class = String) forall T

Returns the Hash value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int

Returns the Int value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int16

Returns the Int16 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int16?

Returns the Int16 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int32

Returns the Int32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int32?

Returns the Int32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int64

Returns the Int64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int64?

Returns the Int64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int8

Returns the Int8 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int8?

Returns the Int8 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_int?

Returns the Int value represented by given YAML::Any type, else raise a TypeCastError exception.

to_string

Alias to Object.to_s

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Array type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Bool type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Float type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Hash type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Int type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given JSON::Any type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Array type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Nil type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given String type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Symbol type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Time type, else raise a TypeCastError exception.

to_time(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given YAML::Any type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Array type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Bool type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Float type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Hash type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Int type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given JSON::Any type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Array type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Nil type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given String type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Symbol type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given Time type, else raise a TypeCastError exception.

to_time?(location : Time::Location | Nil = nil, formatters : Array(String) | Nil = nil)

Returns the Time value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint

Returns the UInt value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint16

Returns the UInt16 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint16?

Returns the UInt16 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint32

Returns the UInt32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint32?

Returns the UInt32 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint64

Returns the UInt64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint64?

Returns the UInt64 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint8

Returns the UInt8 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint8?

Returns the UInt8 value represented by given YAML::Any type, else raise a TypeCastError exception.

to_uint?

Returns the UInt value represented by given YAML::Any type, else raise a TypeCastError exception.