示例#1
0
	Julian operator+(Julian const & j, detail::packaged_year y) {
		year_t year = j.year() + static_cast<year_t>(y.nYears_);
		return Julian(
			year, j.month(),
			j.month() == 2 && j.day() == 29 && !is_julian_leapyear(year) ?
			28 : j.day(), j.hour(), j.minute(), j.second());
	}
示例#2
0
	Julian operator-(Julian const & j, detail::packaged_month m) {
		year_t year = j.year() - m.nMonths_ / 12;
		month_t month = j.month() - m.nMonths_ % 12;
		double adjust = (month - 1) / 12 + (month - 12) / 12;
		year += static_cast<year_t>(adjust);
		month -= static_cast<month_t>(adjust * 12);
		day_t day = j.day() < julian_days_in_month(month, is_julian_leapyear(year)) ?
			j.day() : julian_days_in_month(month, is_julian_leapyear(year));
		return Julian(year, month, day, j.hour(), j.minute(), j.second());
	}
示例#3
0
 void test_JulMonOverflow(){
     Julian jDate = Julian(1999,01,31);
     jDate.add_month(1);
     TS_ASSERT_EQUALS(jDate.day(),28);
     jDate.add_month(-1);
     TS_ASSERT_EQUALS(jDate.day(),28);
     jDate+=3;
     jDate.add_month(13);
     TS_ASSERT_EQUALS(jDate.year(),2000);
     TS_ASSERT_EQUALS(jDate.day(),29);
 }