Class: XMLRPC::DateTime
- Inherits:
-
Object
- Object
- XMLRPC::DateTime
- Defined in:
- lib/xmlrpc/datetime.rb
Instance Attribute Summary collapse
-
#day ⇒ Object
Returns the value of attribute day.
-
#hour ⇒ Object
Returns the value of attribute hour.
-
#min ⇒ Object
Returns the value of attribute min.
-
#month ⇒ Object
(also: #mon)
Returns the value of attribute month.
-
#sec ⇒ Object
Returns the value of attribute sec.
-
#year ⇒ Object
Returns the value of attribute year.
Instance Method Summary collapse
- #==(o) ⇒ Object
-
#initialize(year, month, day, hour, min, sec) ⇒ DateTime
constructor
A new instance of DateTime.
- #to_a ⇒ Object
- #to_date ⇒ Object
- #to_time ⇒ Object
Constructor Details
#initialize(year, month, day, hour, min, sec) ⇒ DateTime
Returns a new instance of DateTime.
108 109 110 111 |
# File 'lib/xmlrpc/datetime.rb', line 108 def initialize(year, month, day, hour, min, sec) self.year, self.month, self.day = year, month, day self.hour, self.min, self.sec = hour, min, sec end |
Instance Attribute Details
#day ⇒ Object
Returns the value of attribute day
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def day @day end |
#hour ⇒ Object
Returns the value of attribute hour
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def hour @hour end |
#min ⇒ Object
Returns the value of attribute min
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def min @min end |
#month ⇒ Object Also known as: mon
Returns the value of attribute month
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def month @month end |
#sec ⇒ Object
Returns the value of attribute sec
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def sec @sec end |
#year ⇒ Object
Returns the value of attribute year
72 73 74 |
# File 'lib/xmlrpc/datetime.rb', line 72 def year @year end |
Instance Method Details
#==(o) ⇒ Object
129 130 131 |
# File 'lib/xmlrpc/datetime.rb', line 129 def ==(o) self.to_a == Array(o) rescue false end |
#to_a ⇒ Object
125 126 127 |
# File 'lib/xmlrpc/datetime.rb', line 125 def to_a [@year, @month, @day, @hour, @min, @sec] end |
#to_date ⇒ Object
121 122 123 |
# File 'lib/xmlrpc/datetime.rb', line 121 def to_date Date.new(*to_a[0,3]) end |
#to_time ⇒ Object
113 114 115 116 117 118 119 |
# File 'lib/xmlrpc/datetime.rb', line 113 def to_time if @year >= 1970 Time.gm(*to_a) else nil end end |