Index: ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb	(revision 343)
+++ ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb	(revision 344)
@@ -3,4 +3,5 @@
 # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109157527311_729550_7234Report.html
 # refs #55
+require 'time'
 include OpenEHR::RM::DataStructures
 include OpenEHR::RM::Common::Archetyped
@@ -65,4 +66,47 @@
           end
         end
+
+        class PointEvent < Event
+
+        end
+
+        class IntervalEvent < Event
+          attr_reader :width, :math_function
+          attr_accessor :sample_count
+
+          def initialize(args = { })
+            super(args)
+            self.width = args[:width]
+            self.math_function = args[:math_function]
+            self.sample_count = args[:sample_count]
+          end
+
+          def width=(width)
+            raise ArgumentError, 'width is mandatory' if width.nil?
+            @width = width
+          end
+
+          def math_function=(math_function)
+            if math_function.nil?
+              raise ArgumentError, 'math_function is mandatory'
+            end
+            @math_function = math_function
+          end
+
+          def interval_start_time
+            date_time = ::Time.iso8601(time.as_string)
+            start_time = (@width.years).years.ago date_time
+            start_time = (@width.months).months.ago start_time
+            start_time = (@width.days).days.ago start_time
+            start_time = (@width.hours).hours.ago start_time
+            start_time = (@width.minutes).minutes.ago start_time
+            seconds = @width.seconds
+            unless @width.fractional_second.nil?
+              seconds += @width.fractional_second
+            end
+            start_time = seconds.ago start_time
+            return DvDateTime.new(:value => start_time.iso8601)
+          end
+        end
       end # end of History
     end # end of DataStructure
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb	(revision 343)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb	(revision 344)
@@ -42,4 +42,3 @@
     @event.offset.value.should == 'P0Y0M0W0DT23H58M53S'
   end
-
 end
Index: ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb
===================================================================
--- ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb	(revision 344)
+++ ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb	(revision 344)
@@ -0,0 +1,43 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::DataStructures::History
+include OpenEHR::RM::DataStructures::ItemStructure
+include OpenEHR::RM::DataTypes::Text
+include OpenEHR::RM::DataTypes::Quantity::DateTime
+
+describe IntervalEvent do
+  before(:each) do
+    time = DvDateTime.new(:value => '2009-11-12T10:19:33')
+    state = stub(ItemStructure, :archetype_node_id => 'at0002')
+    origin = DvDateTime.new(:value => '2009-11-11T10:20:40')
+    parent = stub(History, :origin => origin)
+    math_function = stub(DvCodedText, :value => 'mean')
+    width = DvDuration.new(:value => 'P0Y2M1W3DT5H7M3S')
+    @interval_event = IntervalEvent.new(:archetype_node_id => 'at0001',
+                                :name => DvText.new(:value => 'Event test'),
+                                :time => time,
+                                :data => 'data',
+                                :width => width,
+                                :math_function => math_function, 
+                                :sample_count => 1234)
+  end
+
+  it 'should be an instance of IntervalEvent' do
+    @interval_event.should be_an_instance_of IntervalEvent
+  end
+
+  it 'width should be assigned properly' do
+    @interval_event.width.value.should == 'P0Y2M1W3DT5H7M3S'
+  end
+
+  it 'math_function should be assigned properly' do
+    @interval_event.math_function.value.should == 'mean'
+  end
+
+  it 'sample_count should be assigned properly' do
+    @interval_event.sample_count.should be_equal 1234
+  end
+
+  it 'should subtract time for interval start time' do
+    @interval_event.interval_start_time.value.should == '2009-09-09T05:12:30+09:00'
+  end
+end
