struct Clear::TimeInDay
- Clear::TimeInDay
- Struct
- Value
- Object
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.crConstructors
Class Method Summary
-
.parse(str : String)
Parse a string, of format HH:MM or HH:MM:SS
Instance Method Summary
- #+(t : Time::Span)
- #+(x : self)
- #-(t : Time::Span)
- #hour
-
#inspect
Returns an unambiguous and information-rich string representation of this object, typically intended for developers.
- #microseconds : UInt64
- #minutes
- #seconds
-
#to_s(show_seconds : Bool = true)
Returns a nicely readable and concise string representation of this object, typically intended for users.
-
#to_s(io, show_seconds : Bool = true)
Return a string
- #to_tuple
- #total_seconds
Constructor Detail
Class Method Detail
Instance Method Detail
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
.
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
.