struct

Lustra::TimeInDay

Inherits Struct < Value < Object

Lustra::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 = Lustra::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 Lustra::Model

  column time_in_day : Lustra::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

+(x : self)
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_json(json : JSON::Builder) : Nil
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