Extended maintenance of Ruby versions 1.8.7 and 1.9.2 will end on July 31, 2014. Read more

In Files

  • xmlrpc/datetime.rb

XMLRPC::DateTime

Attributes

day[R]
hour[R]
min[R]
mon[R]
month[R]
sec[R]
year[R]

Public Class Methods

new(year, month, day, hour, min, sec) click to toggle source
 
               # File 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
            

Public Instance Methods

==(o) click to toggle source
 
               # File xmlrpc/datetime.rb, line 129
def ==(o)
  self.to_a == Array(o) rescue false
end
            
day=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 84
def day= (value)
  raise ArgumentError, "date/time out of range" unless (1..31).include? value
  @day = value
end
            
hour=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 89
def hour= (value)
  raise ArgumentError, "date/time out of range" unless (0..24).include? value
  @hour = value
end
            
min=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 94
def min= (value)
  raise ArgumentError, "date/time out of range" unless (0..59).include? value
  @min = value
end
            
mon=(value) click to toggle source
Alias for: month=
month=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 79
def month= (value)
  raise ArgumentError, "date/time out of range" unless (1..12).include? value
  @month = value
end
            
Also aliased as: mon=
sec=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 99
def sec= (value)
  raise ArgumentError, "date/time out of range" unless (0..59).include? value
  @sec = value
end
            
to_a() click to toggle source
 
               # File xmlrpc/datetime.rb, line 125
def to_a
  [@year, @month, @day, @hour, @min, @sec]
end
            
to_date() click to toggle source
 
               # File xmlrpc/datetime.rb, line 121
def to_date
  Date.new(*to_a[0,3])
end
            
to_time() click to toggle source
 
               # File xmlrpc/datetime.rb, line 113
def to_time
  if @year >= 1970
    Time.gm(*to_a)
  else
    nil
  end
end
            
year=(value) click to toggle source
 
               # File xmlrpc/datetime.rb, line 74
def year= (value)
  raise ArgumentError, "date/time out of range" unless value.is_a? Integer
  @year = value
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus