Class: XMLRPC::DateTime
| Relationships & Source Files | |
| Inherits: | Object | 
| Defined in: | lib/xmlrpc/datetime.rb | 
Overview
Class Method Summary
Instance Attribute Summary
- 
    
      #day  
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #day=(value)  
    
    rw
    Set valueas the new date/time component.
- 
    
      #hour  
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #hour=(value)  
    
    rw
    Set valueas the new date/time component.
- 
    
      #min  
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #min=(value)  
    
    rw
    Set valueas the new date/time component.
- 
    
      #mon  
    
    rw
    Alias for #month. 
- 
    
      #month  
      (also: #mon)
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #month=(value)  
      (also: #mon=)
    
    rw
    Set valueas the new date/time component.
- 
    
      #sec  
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #sec=(value)  
    
    rw
    Set valueas the new date/time component.
- 
    
      #year  
    
    rw
    Return the value of the specified date/time component. 
- 
    
      #year=(value)  
    
    rw
    Set valueas the new date/time component.
Instance Method Summary
Constructor Details
    .new(year, month, day, hour, min, sec)  ⇒ DateTime 
  
Instance Attribute Details
#day (rw)
Return the value of the specified date/time component.
#day=(value) (rw)
Set value as the new date/time component.
Raises an ArgumentError if the given value isn't between 1 and 31.
# File 'lib/xmlrpc/datetime.rb', line 43
def day=(value) raise ArgumentError, "date/time out of range" unless (1..31).include? value @day = value end
#hour (rw)
Return the value of the specified date/time component.
#hour=(value) (rw)
Set value as the new date/time component.
Raises an ArgumentError if the given value isn't between 0 and 24.
# File 'lib/xmlrpc/datetime.rb', line 51
def hour=(value) raise ArgumentError, "date/time out of range" unless (0..24).include? value @hour = value end
#min (rw)
Return the value of the specified date/time component.
#min=(value) (rw)
Set value as the new date/time component.
Raises an ArgumentError if the given value isn't between 0 and 59.
# File 'lib/xmlrpc/datetime.rb', line 59
def min=(value) raise ArgumentError, "date/time out of range" unless (0..59).include? value @min = value end
#mon (rw)
Alias for #month.
# File 'lib/xmlrpc/datetime.rb', line 73
alias mon month
#month (rw) Also known as: #mon
Return the value of the specified date/time component.
#month=(value) (rw) Also known as: #mon=
Set value as the new date/time component.
Raises an ArgumentError if the given value isn't between 1 and 12.
# File 'lib/xmlrpc/datetime.rb', line 35
def month=(value) raise ArgumentError, "date/time out of range" unless (1..12).include? value @month = value end
#sec (rw)
Return the value of the specified date/time component.
#sec=(value) (rw)
Set value as the new date/time component.
Raises an ArgumentError if the given value isn't between 0 and 59.
# File 'lib/xmlrpc/datetime.rb', line 67
def sec=(value) raise ArgumentError, "date/time out of range" unless (0..59).include? value @sec = value end
#year (rw)
Return the value of the specified date/time component.
#year=(value) (rw)
Set value as the new date/time component.
Raises ArgumentError if the given value is out of range, or in the case of year= if value is not of type Integer.
# File 'lib/xmlrpc/datetime.rb', line 27
def year=(value) raise ArgumentError, "date/time out of range" unless value.is_a? Integer @year = value end
Instance Method Details
#==(o)
Returns whether or not all date/time components are an array.
# File 'lib/xmlrpc/datetime.rb', line 111
def ==(o) self.to_a == Array(o) rescue false end
#to_a
Returns all date/time components in an array.
Returns [year, month, day, hour, min, sec].
# File 'lib/xmlrpc/datetime.rb', line 106
def to_a [@year, @month, @day, @hour, @min, @sec] end
#to_date
Return a Date object of the date which represents self.
The Date object do not contain the time component (only date).
#to_time
Return a Time object of the date/time which represents self.
The timezone used is GMT.
# File 'lib/xmlrpc/datetime.rb', line 92
def to_time Time.gm(*to_a) end