Date Date::addYearsGet(const long& years) { long g = getDays(year+years,month,day); Date d = getDateFromDays(g); d.epochTime = getSecondsI(d.year, d.month, d.day, d.hours, d.minutes, d.seconds); return d; }
int Date::test() { unsigned long long gg = getDays(2008,12,31); getDateFromDays(gg); gg = getHours(2008,12,31,12); getDateFromHours(gg); gg = getMinutes(2008,12,31,12,56); getDateFromMinutes(gg); gg = getSeconds(2008,12,31,12,56,56); getDateFromSeconds(gg); Date d; //logger << d.toString() << endl; Date d1 = addYearsGet(1); //logger << d1.toString() << endl; Date d2 = addMonthsGet(23); //logger << d2.toString() << endl; Date d3 = addDaysGet(17); //logger << d3.toString() << endl; Date d4 = addHoursGet(25); //logger << d4.toString() << endl; Date d5 = addMinutesGet(61); //logger << d5.toString() << endl; Date d6 = addSecondsGet(61); //logger << d6.toString() << endl; return 0; }
Date Date::addDaysGet(long days) { long months = getMonth(); long year = getYear() + months/12; months = months%12; long g = getDays(year,months,getDay()+days); return getDateFromDays(g); }
Date Date::addMonthsGet(long months) { months = getMonth() + months; long year = getYear() + months/12; months = months%12; long g = getDays(year,months,getDay()); return getDateFromDays(g); }
Date::Date(int yyyy,int mm,int dd) { if(!validateDate(dd,mm,yyyy))throw "Invalid date"; long g = getDays(yyyy,mm,dd); *this = getDateFromDays(g); this->nanoseconds = 0; this->timeZoneOffset = 0; }
Date::Date(const int& yyyy, const int& mm, const int& dd) { if(!validateDate(dd,mm,yyyy))throw std::runtime_error("Invalid date"); long g = getDays(yyyy,mm,dd); *this = getDateFromDays(g); populateDay(); populateMonth(); populateEpochAndTimeZone(false); }
void Date::updateYears(long years) { long g = getDays(getYear()+years,getMonth(),getDay()); Date d = getDateFromDays(g); setDay(d.getDay()); setMonth(d.getMm()); setYear(d.getYear()); setDayw(d.getDayw()); }
Date Date::addMonthsGet(long months) { months = month + months; long year = this->year + months/12; months = months%12; long g = getDays(year,months,day); Date d = getDateFromDays(g); d.epochTime = getSecondsI(d.year, d.month, d.day, d.hours, d.minutes, d.seconds); return d; }
Date Date::addDaysGet(const long& days) { long months = month; long year = this->year + months/12; months = months%12; long g = getDays(year,months,day+days); Date d = getDateFromDays(g); d.epochTime += days*24*3600; return d; }
Date::Date(int yyyy,string mmm,int dd) { string mm = getMon(mmm); if(mm=="-1")throw "Invalid month"; if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw "Invalid date"; long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd); *this = getDateFromDays(g); this->nanoseconds = 0; this->timeZoneOffset = 0; }
void Date::updateYears(const long& years) { long g = getDays(year+years,month,day); Date d = getDateFromDays(g); this->day = d.day; this->month = d.month; this->year = d.year; populateDay(); epochTime = getSecondsI(year, month, day, hours, minutes, seconds); }
Date::Date(int yy,int mm,int dd,bool te) { Date d; string syyyy = d.year.substr(0,2) + CastUtil::lexical_cast<string>(yy); int yyyy = CastUtil::lexical_cast<int>(syyyy); if(!validateDate(dd,mm,yyyy))throw "Invalid date"; long g = getDays(yyyy,mm,dd); *this = getDateFromDays(g); this->nanoseconds = 0; this->timeZoneOffset = 0; }
Date::Date(const int& yyyy, const std::string& mmm, const int& dd) { std::string mm = getMon(mmm); if(mm=="-1")throw std::runtime_error("Invalid month"); if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw std::runtime_error("Invalid date"); long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd); *this = getDateFromDays(g); populateDay(); populateMonth(); populateEpochAndTimeZone(false); }
void Date::updateMonths(long months) { months = getMonth() + months; long year = getYear() + months/12; months = months%12; long g = getDays(year,months,getDay()); Date d = getDateFromDays(g); setDay(d.getDay()); setMonth(d.getMm()); setYear(d.getYear()); setDayw(d.getDayw()); }
Date::Date(const int& yy, const int& mm, const int& dd, const bool& te) { Date d; std::string syyyy = CastUtil::lexical_cast<std::string>(d.year).substr(0,2) + CastUtil::lexical_cast<std::string>(yy); int yyyy = CastUtil::lexical_cast<int>(syyyy); if(!validateDate(dd,mm,yyyy))throw std::runtime_error("Invalid date"); long g = getDays(yyyy,mm,dd); *this = getDateFromDays(g); populateDay(); populateMonth(); populateEpochAndTimeZone(false); }
void Date::updateDays(const long& days) { long months = month; long year = this->year + months/12; months = months%12; long g = getDays(year,months,day+days); Date d = getDateFromDays(g); this->day = d.day; this->month = d.month; this->year = d.year; populateDay(); epochTime += days*24*60*60; }
void Date::updateMonths(long months) { months = month + months; long year = this->year + months/12; months = months%12; long g = getDays(year,months,day); Date d = getDateFromDays(g); this->day = d.day; this->month = d.month; this->year = d.year; populateDay(); epochTime = getSecondsI(year, month, day, hours, minutes, seconds); }
Date::Date(int yy,string mmm,int dd,bool te) { Date d; string syyyy = d.year.substr(0,2) + CastUtil::lexical_cast<string>(yy); int yyyy = CastUtil::lexical_cast<int>(syyyy); string mm = getMon(mmm); if(mm=="-1")throw "Invalid month"; if(!validateDate(dd,CastUtil::lexical_cast<int>(mm),yyyy))throw "Invalid date"; long g = getDays(yyyy,CastUtil::lexical_cast<long>(mm),dd); *this = getDateFromDays(g); this->nanoseconds = 0; this->timeZoneOffset = 0; setDayName(); }
Date Date::addYearsGet(long years) { long g = getDays(getYear()+years,getMonth(),getDay()); return getDateFromDays(g); }