Class: DBI::Date
- Inherits:
-
Object
- Object
- DBI::Date
- Defined in:
- lib/dbi/utils/date.rb
Overview
Represents a Date.
DEPRECATED: Please use a regular Date or DateTime object.
Instance Attribute Summary collapse
-
#day ⇒ Object
(also: #mday)
Returns the value of attribute day.
-
#month ⇒ Object
(also: #mon)
Returns the value of attribute month.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
-
#to_date ⇒ Object
Returns a new Date object based on the year, month and day or, if a Date object was passed to the constructor, returns that object.
-
#to_s ⇒ Object
Returns a DBI::Date object as a string in YYYY-MM-DD format.
-
#to_time ⇒ Object
Returns a new Time object based on the year, month and day or, if a Time object was passed to the constructor, returns that object.
Instance Attribute Details
#day ⇒ Object Also known as: mday
Returns the value of attribute day.
8 9 10 |
# File 'lib/dbi/utils/date.rb', line 8 def day @day end |
#month ⇒ Object Also known as: mon
Returns the value of attribute month.
8 9 10 |
# File 'lib/dbi/utils/date.rb', line 8 def month @month end |
#year ⇒ Object
Returns the value of attribute year.
8 9 10 |
# File 'lib/dbi/utils/date.rb', line 8 def year @year end |
Instance Method Details
#to_date ⇒ Object
Returns a new Date object based on the year, month and day or, if a Date object was passed to the constructor, returns that object.
24 25 26 |
# File 'lib/dbi/utils/date.rb', line 24 def to_date @original_date || ::Date.new(@year, @month, @day) end |
#to_s ⇒ Object
Returns a DBI::Date object as a string in YYYY-MM-DD format.
29 30 31 |
# File 'lib/dbi/utils/date.rb', line 29 def to_s sprintf("%04d-%02d-%02d", @year, @month, @day) end |
#to_time ⇒ Object
Returns a new Time object based on the year, month and day or, if a Time object was passed to the constructor, returns that object.
18 19 20 |
# File 'lib/dbi/utils/date.rb', line 18 def to_time @original_time || ::Time.local(@year, @month, @day, 0, 0, 0) end |