//---------------------------------------------------------------------------- //---------------------------------------------------------------------------- // Expand this encoded partial date/time to a Date_Time in the calendar // year of the given reference Date_Time. This is done by constructing // a full Date_Time from the defined partial date/time "parts" plus the // other parts from the reference date/time (with adjustments made for // different-sized months). // // FOR EXAMPLE: // This partial dt: March 12 // Ref date/time: July 23, 2009, 6:30 am // Result: March 12, 2009, 6:30 am // // This partial dt: 31st day of the month // Ref date/time: February 14, 2008, 9:20 pm (a leap year) // Result: Feburary 29, 2008, 9:20 pm (day clipped to end of Feb) // //-- void PartialDateTimeEncoder::expandToCalendarYearAtDateTime ( Date_Time& resultFullDT, const Date_Time& refDT) const { // First check if this partial date/time is "absolute". If so, just // return its Date_Time. (The given Reference Date_Time is not used). // if (_negPartBits == PartialDateTime::NegPartBits_Absolute) { resultFullDT = _dtime; return; //---------->> } // Compute the result date/time parts from the defined partial date/time // "parts" and (for the other parts) the Reference Date_Time parts. // int resYear = showYear() ?_dtime.get_year() :refDT.get_year(); int resMon1 = showMonth() ?_dtime.get_month() :refDT.get_month(); // [1..12] int resMDay = showDay() ?_dtime.get_mday() :refDT.get_mday(); // [1..31] int resHour = showHour() ?_dtime.get_hour() :refDT.get_hour(); int resMin = showMins() ?_dtime.get_min() :refDT.get_min(); int resSec = showSecs() ?_dtime.get_sec() :refDT.get_sec(); // Fixup month day, considering the length of the result month. const int monthDays = Date_Time::daysInMonth (resYear, resMon1); // [1..12] resMDay = std::min (resMDay, monthDays); resultFullDT.setTime (resYear, resMon1, resMDay, resHour, resMin, resSec); } //---------------------------------------------------------------------------- //----------------------------------------------------------------------------