struct Time

Overview

Time cast methods

Included Modules

Defined in:

popcorn/cast/int.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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:00 UTC).

The time zone is always UTC.

Time.unix(981173106) # => 2001-02-03 04:05:06 UTC

[View source]
def self.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:00 UTC).

The time zone is always UTC.

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

[View source]

Instance Method Detail

def cast(other) #

def cast?(other) #

def to_array(value_type : T.class = String) forall T #

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


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

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


def to_bool #

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


def to_bool? #

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


def to_float #

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


def to_float32 #

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


def to_float32? #

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


def to_float64 #

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


def to_float64? #

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


def to_float? #

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


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

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


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

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


def to_int #

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


def to_int16 #

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


def to_int16? #

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


def to_int32 #

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


def to_int32? #

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


def to_int64 #

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


def to_int64? #

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


def to_int8 #

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


def to_int8? #

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


def to_int? #

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


def to_string #

Alias to Object.to_s


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def 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.


def to_uint #

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


def to_uint16 #

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


def to_uint16? #

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


def to_uint32 #

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


def to_uint32? #

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


def to_uint64 #

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


def to_uint64? #

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


def to_uint8 #

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


def to_uint8? #

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


def to_uint? #

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