def diff_in_days(date_to_compare)
      # d1 will be the earlier date, d2 the later
      if date_to_compare > self
        d1, d2 = dup, date_to_compare.dup
      elsif self > date_to_compare
        d1, d2 = date_to_compare.dup, dup
      else
        return 0  # same date
      end

      total = 0
      while d1.year != d2.year
        total += d1.days_left_in_year + 1 # need one extra day to push us to jan 1
        d1 = ZDate.new(ZDate.format_date(d1.year + 1))
      end
      total += d2.day_of_year - d1.day_of_year
      total
    end
def diff_in_days(date_to_compare)
      # d1 will be the earlier date, d2 the later
      if date_to_compare > self
        d1, d2 = dup, date_to_compare.dup
      elsif self > date_to_compare
        d1, d2 = date_to_compare.dup, dup
      else
        return 0  # same date
      end

      total = 0
      while d1.year != d2.year
        total += d1.days_left_in_year + 1 # need one extra day to push us to jan 1
        d1 = ZDate.new(ZDate.format_date(d1.year + 1))
      end
      total += d2.day_of_year - d1.day_of_year
      total
    end
Gets the absolute difference in days between self and date_to_compare, order is not important.