- Timestamp:
- Sep 29, 2009, 11:12:37 AM (15 years ago)
- Location:
- ruby/branches/0.5
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb
r309 r311 60 60 day = future.day - past.day 61 61 else 62 month -=162 month = -1 63 63 previous_month = future.month - 1 64 if previous_month <= 064 if previous_month == 0 65 65 previous_month = 12 66 66 end … … 76 76 year -= 1 77 77 month += future.month + 12 - past.month 78 end 79 if month < 0 80 year -= 1 81 month += 12 78 82 end 79 83 year += future.year - past.year -
ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_spec.rb
r310 r311 31 31 end 32 32 33 it 'diff should P0Y0M1W1 0D' do33 it 'diff should P0Y0M1W11D' do 34 34 diff_date = DvDate.new(:value => '2009-10-09') 35 35 @dv_date.diff(diff_date).value.should == 'P0Y0M1W11D' 36 36 end 37 38 it 'should process leap year' do 39 @dv_date.value = '2004-02-28' 40 diff_date = DvDate.new(:value => '2004-03-01') 41 @dv_date.diff(diff_date).value.should == 'P0Y0M0W2D' 42 end 43 44 it 'should process year'do 45 diff_date = DvDate.new(:value => '2007-12-31') 46 @dv_date.diff(diff_date).value.should == 'P1Y8M4W28D' 47 end 48 49 it 'should be P0Y11M4W31D' do 50 diff_date = DvDate.new(:value => '2008-09-30') 51 @dv_date.diff(diff_date).value.should == 'P0Y11M4W29D' 52 end 53 54 it 'should be P1Y0M0W1D' do 55 diff_date = DvDate.new(:value => '2010-09-29') 56 @dv_date.diff(diff_date).value.should == 'P1Y0M0W1D' 57 end 58 59 it 'should be P0Y0M0W1D' do 60 past_date = DvDate.new(:value => '2009-12-31') 61 future_date=DvDate.new(:value => '2010-01-01') 62 past_date.diff(future_date).value.should == 'P0Y0M0W1D' 63 end 37 64 end
Note:
See TracChangeset
for help on using the changeset viewer.