JulianDate::DateDecomposition JulianDate::getDecomposition() const { const int D4 = 365 * 4 + 1; const int D1 = 365; const int d = mod_julian_day() - JULIAN_DAY_ZERO_MJD_OFFSET; const int c4 = d / D4; const int d4 = d % D4; const int cp1 = std::min(d4 / (D1 + 1), 1); const int dp1 = d4 - cp1 * (D1 + 1); const int cb1 = cp1 * dp1 / D1; const int db1 = dp1 - cb1 * D1; return DateDecomposition{4 * c4 + cp1 + cb1, db1}; }
int Date::operator-(const Date & d) const { return mod_julian_day() - d.mod_julian_day(); }
bool Date::operator<(const Date & d) const { return mod_julian_day() < d.mod_julian_day(); }
bool Date::operator>=(const Date & d) const { return mod_julian_day() >= d.mod_julian_day(); }
Julian::Julian(const Date & date) : GreLian(date) { int diff = mod_julian_day() - date.mod_julian_day(); *this -= diff; }
Julian::Julian(Date* & dp) : GreLian(*dp) { int diff = mod_julian_day() - dp->mod_julian_day(); *this -= diff; }
lab2::Gregorian::Gregorian(const lab2::Date &date) { _year = date.year(); _month = date.month(); _day = date.day(); *this += date.mod_julian_day()-mod_julian_day(); }
unsigned int WesternDate::week_day() const { int wd = (mod_julian_day()+ 2) % wkds.size(); ++wd; return wd; }
int Date::operator -(const Date & d) const{ int diff = mod_julian_day() - d.mod_julian_day(); /*if (diff < 0) return diff * -1;*/ return diff; }
bool Date::operator<=(const Date &date) const { return mod_julian_day() <= date.mod_julian_day(); }
const bool Date::operator>(const Date& d) const{ return (mod_julian_day() > d.mod_julian_day()); }