DateTime::DateTime() { Timestamp now; _utcTime = now.utcTime(); computeGregorian(julianDay()); computeDaytime(); }
DateTime& DateTime::operator = (const Timestamp& timestamp) { _utcTime = timestamp.utcTime(); computeGregorian(julianDay()); computeDaytime(); return *this; }
DateTime& DateTime::operator -= (const Timespan& span) { _utcTime -= span.totalMicroseconds()*10; computeGregorian(julianDay()); computeDaytime(); return *this; }
DateTime& DateTime::operator += (const Timespan& span) { _utcTime += span*10; computeGregorian(julianDay()); computeDaytime(); return *this; }
static int weekNumber(const Date *theDate) { int J = julianDay(theDate); int d4 = (J+31741-(J%7))%146097%36524%1461; int L = (int)(d4/1460); int d1 = ((d4-L)%365)+L; return (int)(d1/7)+1; }
bool Date::setDate (int year, int month, int day) { if (isValid(year, month, day)) m_jd = julianDay(year, month, day); else m_jd = NullJulianDay; return isValid(); }
static int dayOfWeek(const Date *theDate) { int J = julianDay(theDate); return (J+1)%7; }
DateTime::DateTime(const Timestamp& timestamp): _utcTime(timestamp.utcTime()) { computeGregorian(julianDay()); computeDaytime(); }
int DateTime::dayOfWeek() const { return int((std::floor(julianDay() + 1.5))) % 7; }
DateTime::DateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff): _utcTime(utcTime + diff*10) { computeGregorian(julianDay()); computeDaytime(); }
/** * @brief Returns the day of the year (1 to 365 or 366 on leap years) for this date. * * @return The day of the year (1 to 365 or 366 on leap years) for this date, or 0 if the date is invalid. */ int Date::dayOfYear() const { return !isValid() ? 0 : m_jd - julianDay(year(), 1, 1) + 1; }