3 Copyright (C) 2001, 2002, 2003 by Michael Neumann (mneumann@ntecs.de)
5 Released under the same term of license as Ruby.
8 * ((<XMLRPC::DateTime>))
12 This class is important to handle XMLRPC (('dateTime.iso8601')) values,
13 correcly, because normal UNIX-dates (class (({Date}))) only handle dates
14 from year 1970 on, and class (({Time})) handles dates without the time
15 component. (({XMLRPC::DateTime})) is able to store a XMLRPC
16 (('dateTime.iso8601')) value correctly.
19 --- XMLRPC::DateTime.new( year, month, day, hour, min, sec )
20 Creates a new (({XMLRPC::DateTime})) instance with the
21 parameters ((|year|)), ((|month|)), ((|day|)) as date and
22 ((|hour|)), ((|min|)), ((|sec|)) as time.
23 Raises (({ArgumentError})) if a parameter is out of range, or ((|year|)) is not
24 of type (({Integer})).
27 --- XMLRPC::DateTime#year
28 --- XMLRPC::DateTime#month
29 --- XMLRPC::DateTime#day
30 --- XMLRPC::DateTime#hour
31 --- XMLRPC::DateTime#min
32 --- XMLRPC::DateTime#sec
33 Return the value of the specified date/time component.
35 --- XMLRPC::DateTime#mon
36 Alias for ((<XMLRPC::DateTime#month>)).
38 --- XMLRPC::DateTime#year=( value )
39 --- XMLRPC::DateTime#month=( value )
40 --- XMLRPC::DateTime#day=( value )
41 --- XMLRPC::DateTime#hour=( value )
42 --- XMLRPC::DateTime#min=( value )
43 --- XMLRPC::DateTime#sec=( value )
44 Set ((|value|)) as the new date/time component.
45 Raises (({ArgumentError})) if ((|value|)) is out of range, or in the case
46 of (({XMLRPC::DateTime#year=})) if ((|value|)) is not of type (({Integer})).
48 --- XMLRPC::DateTime#mon=( value )
49 Alias for ((<XMLRPC::DateTime#month=>)).
51 --- XMLRPC::DateTime#to_time
52 Return a (({Time})) object of the date/time which (({self})) represents.
53 If the (('year')) is below 1970, this method returns (({nil})),
54 because (({Time})) cannot handle years below 1970.
55 The used timezone is GMT.
57 --- XMLRPC::DateTime#to_date
58 Return a (({Date})) object of the date which (({self})) represents.
59 The (({Date})) object do ((*not*)) contain the time component (only date).
61 --- XMLRPC::DateTime#to_a
62 Returns all date/time components in an array.
63 Returns (({[year, month, day, hour, min, sec]})).
72 attr_reader :year, :month, :day, :hour, :min, :sec
75 raise ArgumentError, "date/time out of range" unless value.is_a? Integer
80 raise ArgumentError, "date/time out of range" unless (1..12).include? value
85 raise ArgumentError, "date/time out of range" unless (1..31).include? value
90 raise ArgumentError, "date/time out of range" unless (0..24).include? value
95 raise ArgumentError, "date/time out of range" unless (0..59).include? value
100 raise ArgumentError, "date/time out of range" unless (0..59).include? value
108 def initialize(year, month, day, hour, min, sec)
109 self.year, self.month, self.day = year, month, day
110 self.hour, self.min, self.sec = hour, min, sec
126 [@year, @month, @day, @hour, @min, @sec]
130 self.to_a == Array(o) rescue false