struct Clear::TimeInDay

Overview

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

Defined in:

clear/extensions/time/time_in_day.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(hours, minutes, seconds = 0) #

[View source]
def self.new(microseconds : UInt64 = 0) #

[View source]

Class Method Detail

def self.parse(str : String) #

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


[View source]

Instance Method Detail

def +(t : Time::Span) #

[View source]
def +(x : self) #

[View source]
def -(t : Time::Span) #

[View source]
def hour #

[View source]
def inspect #
Description copied from class Object

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.


[View source]
def microseconds : UInt64 #

[View source]
def minutes #

[View source]
def seconds #

[View source]
def to_s(show_seconds : Bool = true) #
Description copied from class Object

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.


[View source]
def to_s(io, show_seconds : Bool = true) #

Return a string


[View source]
def to_tuple #

[View source]
def total_seconds #

[View source]