anchor.diff:      end function less_than
   
       ! note, this requires the time_delta object
  -    function difference(time1, time2) result(dt)
  -        implicit none
  -        class(Time_type), intent(in) :: time1, time2
  +    function difference(t1, t2) result(dt)
  +        implicit none
  +        class(Time_type), intent(in) :: t1, t2
           type(time_delta_t) :: dt
   
  -        call dt%set_time_delta(days=time1%mjd() - time2%mjd())
  +        type(Time_type) :: temp_time
  +        integer :: year, month, day, hour, minute, second
  +
  +        if (((t1%calendar == t2%calendar).and.(t1%year_zero == t2%year_zero)) &
  +            .and.((t1%month_zero == t2%month_zero).and.(t1%day_zero == t2%day_zero))) then
  +
  +            call dt%set_time_delta(days=t1%mjd() - t2%mjd())
  +        else
  +            ! if the two time object reference calendars don't match
  +            ! create a new time object with the same referecnce as t1
  +            ! then copy the date/time data into it from t2 before computing the time delta
  +            call temp_time%init(t1%calendar,t1%year_zero,t1%month_zero,t1%day_zero)
  +            call t1%date(year, month, day, hour, minute, second)
  +            call temp_time%set(year, month, day, hour, minute, second)
  +
  +            call dt%set_time_delta(days=t1%mjd() - temp_time%mjd())
  +        endif
   
       end function difference
   
  
positive.code:             this%day_zero = day_zero
          endif
  
      end subroutine time_init
  
      !>------------------------------------------------------------
      !!  Set the calendar from a given name
  
negative.code:             if (this%year_zero == NON_VALID_YEAR) then
                  jday = nint(mjd+2400000.5)
              else
                  jday = nint(mjd + gregorian_julian_day(this%year_zero, this%month_zero, this%day_zero, 0, 0, 0))
              endif
              f = jday+j+(((4*jday+B)/146097)*3)/4+C
              e = r*f+v
  