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