Index: ruby/trunk/lib/models/assumed_library_types.rb
===================================================================
--- ruby/trunk/lib/models/assumed_library_types.rb	(revision 143)
+++ ruby/trunk/lib/models/assumed_library_types.rb	(revision 149)
@@ -165,4 +165,13 @@
         month_unknown? or day_unknown?
       end
+
+      protected
+      def leapyear?(year)
+        case
+        when year % 400 == 0: true
+        when year % 100 == 0: false
+        else year % 4 == 0
+        end
+      end
     end
 
@@ -187,4 +196,5 @@
         end
       end
+
       def self.valid_iso8601_date?(string)
         begin
@@ -353,50 +363,6 @@
     end # end of ISO8601_TIME
 
-    class ISO8601_DATE_TIME < ISO8601_DATE
-      include ISO8601_TIME_MODULE, ISO8601_DATE_MODULE
-      def initialize(string)
-        /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
-        if $1.empty?
-          raise ArgumentError, 'format invalid'
-        else
-          self.year = $1.to_i
-        end
-        if $2.nil?
-          self.month = nil
-        else
-          self.month = $2.to_i
-        end
-        if $3.nil?
-          self.day = nil
-        else
-          self.day = $3.to_i
-        end
-        if $5.nil?
-          self.minute = nil
-        else
-          self.minute = $5.to_i
-        end
-        if $6.nil?
-          self.second = nil
-        else
-          self.second = $6.to_i
-        end
-        if $4.nil?
-          self.hour = nil
-        else
-          self.hour = $4.to_i
-        end
-        if $7.nil? or $7.empty?
-          self.fractional_second = nil
-        else
-          self.fractional_second = ("0."+$7).to_f
-        end
-        if $8.nil?
-          self.timezone = nil
-        else
-          self.timezone = $9+$10
-        end
-      end
-
+    module ISO8601_DATE_TIME_MODULE
+      include ISO8601_DATE_MODULE, ISO8601_TIME_MODULE
       def as_string
         if (!@year.nil? and !@month.nil? and !@day.nil?)
@@ -424,7 +390,53 @@
         return s
       end
-
     end
 
+    class ISO8601_DATE_TIME < ISO8601_DATE
+      include ISO8601_DATE_TIME_MODULE
+      def initialize(string)
+        /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
+        if $1.empty?
+          raise ArgumentError, 'format invalid'
+        else
+          self.year = $1.to_i
+        end
+        if $2.nil?
+          self.month = nil
+        else
+          self.month = $2.to_i
+        end
+        if $3.nil?
+          self.day = nil
+        else
+          self.day = $3.to_i
+        end
+        if $5.nil?
+          self.minute = nil
+        else
+          self.minute = $5.to_i
+        end
+        if $6.nil?
+          self.second = nil
+        else
+          self.second = $6.to_i
+        end
+        if $4.nil?
+          self.hour = nil
+        else
+          self.hour = $4.to_i
+        end
+        if $7.nil? or $7.empty?
+          self.fractional_second = nil
+        else
+          self.fractional_second = ("0."+$7).to_f
+        end
+        if $8.nil?
+          self.timezone = nil
+        else
+          self.timezone = $9+$10
+        end
+      end
+    end
+  
     class ISO8601_TIMEZONE
       attr_accessor :sign, :hour, :minute
@@ -444,19 +456,7 @@
     end # end of ISO8601_TIMEZONE
 
-    class ISO8601_DURATION < TIME_DEFINITIONS
+    module ISO8601_DURATION_MODULE
       attr_reader :years, :months, :weeks, :days
       attr_reader :hours, :minutes, :seconds, :fractional_second
-
-      def initialize(str)
-        /^P((\d+)Y)?((\d+)M)?((\d+)W)?((\d)D)?(T((\d+)H)?((\d+)M)?((\d+)(\.\d+)?S)?)?$/ =~ str
-        self.years = $2.to_i
-        self.months = $4.to_i
-        self.weeks = $6.to_i
-        self.days = $8.to_i
-        self.hours = $11.to_i
-        self.minutes = $13.to_i
-        self.seconds = $15.to_i
-        self.fractional_second = $16.to_f
-      end
 
       def years=(years)
@@ -545,4 +545,18 @@
         return str
       end
+    end
+    class ISO8601_DURATION < TIME_DEFINITIONS
+      include ISO8601_DURATION_MODULE
+      def initialize(str)
+        /^P((\d+)Y)?((\d+)M)?((\d+)W)?((\d)D)?(T((\d+)H)?((\d+)M)?((\d+)(\.\d+)?S)?)?$/ =~ str
+        self.years = $2.to_i
+        self.months = $4.to_i
+        self.weeks = $6.to_i
+        self.days = $8.to_i
+        self.hours = $11.to_i
+        self.minutes = $13.to_i
+        self.seconds = $15.to_i
+        self.fractional_second = $16.to_f
+      end
     end # end of ISO8601_DURATION
   end # end of Assumed_Types
