struct

Clear::TimeInDay

Inherits Struct < Value < Object

Clear::TimeInDay represents the "time" object of PostgreSQL

It can be converted automatically from/to a time column. It offers helpers which makes it usable also as a stand alone.

Usage example

time = Clear::TimeInDay.parse("12:33")
puts time.hour    # 12
puts time.minutes # 0

Time.local.at(time) # Today at 12:33:00
time.to_s           # 12:33:00
time.to_s(false)    # don't show seconds => 12:33

time = time + 2.minutes # 12:35

As with Interval, you might wanna use it as a column (use underlying time type in PostgreSQL):

class MyModel
  include Clear::Model

  column i : Clear::TimeInDay
end

Constructors

new(hours, minutes, seconds = 0)
Source
new(microseconds : UInt64 = 0)
Source

Class methods

parse(str : String)

Parse a string, of format HH:MM or HH:MM:SS

Source

Instance methods

+(other : Time::Span)
Source
+(other : self)
Source
-(other : Time::Span)
Source
hour
Source
inspect

Returns an unambiguous and information-rich string representation of this object, typically intended for developers.

This method should usually not be overridden. It delegates to #inspect(IO) which can be overridden for custom implementations.

Also see #to_s.

Source
microseconds
Source
minutes
Source
seconds
Source
to_s(show_seconds : Bool = true)

Returns a nicely readable and concise string representation of this object, typically intended for users.

This method should usually not be overridden. It delegates to #to_s(IO) which can be overridden for custom implementations.

Also see #inspect.

Source
to_s(io, show_seconds : Bool = true)

Return a string

Source
to_tuple
Source
total_seconds
Source

Nested types