Beispiel #1
0
//given a date and entry of a students bill, check if this entry is in the same
//month as the given date
bool student::entryInMonth(feePaymentEntry entry, boost::gregorian::date d){
    if((entry.getDate().month() == d.month()) && 
            (entry.getDate().year() == d.year())){
        return true;
    }
    else { 
        return false;
    }
}
Beispiel #2
0
/// <summary>Adds years to the specified date.</summary>
///
/// <returns>The incremented date.</returns>
///
/// <remarks>The years could be negative. A day of February 29 is changed to
/// February 28 to be sure there is no leap-year problem.</remarks>
///
/// <param name="theDate">The date to add to.</param>
/// <param name="years">The number of years to add.</param>
boost::gregorian::date Date::addYears( boost::gregorian::date theDate,
 int years )
{
   const unsigned short month = theDate.month();
   const unsigned short day = theDate.day();
   const unsigned short day1 = (month == boost::date_time::Feb && day == 29) ?
      28 : day;
   return boost::gregorian::date(
      static_cast<unsigned short>(theDate.year() + years), month, day1);
}
		void CalendarDateInterfacePage::Display(
			std::ostream& stream,
			boost::shared_ptr<const Webpage> page,
			const server::Request& request,
			const util::ParametersMap& templateParametersMap,
			boost::gregorian::date value,
			bool isActive
		){
			ParametersMap pm(templateParametersMap);

			pm.insert(DATA_DAY, value.day());
			pm.insert(DATA_MONTH, value.month());
			pm.insert(DATA_YEAR, value.year());
			pm.insert(DATA_WEEK_DAY, value.day_of_week());
			pm.insert(DATA_IS_ACTIVE, isActive);

			page->display(stream, request, pm);
		}
bool SqliteObject::deleteDay(const boost::gregorian::date &d) 
{

  //std::cout << boost::gregorian::to_simple_string(d) << std::endl;

  boost::gregorian::greg_day gd = d.day();
  std::stringstream ssd;
  ssd << gd.as_number();
  std::string d_day = ssd.str();

  boost::gregorian::greg_month gm = d.month();
  std::stringstream ssm;
  ssm << gm.as_number();
  std::string d_month = ssm.str();

  //std::cout << " " << d_month << " " << d_day << std::endl;

  // What are the timeindex values to delete
  std::stringstream cmd1;
  cmd1 << "select TimeIndex from Time where month=" << d_month << " and day=" << d_day;
  execute(cmd1.str());

  std::vector<int> time_index(0);
  for(size_t r=0; r<m_results->data.size(); ++r){
    time_index.push_back(atoi(m_results->data[r][0].c_str()));
  }

  // What are the ReportExtendedData records associated with the timeindex values from ReportData to delete
  std::stringstream cmd3;
  std::vector<int> RVEDV_index(0);
  for(size_t s=0; s<time_index.size(); ++s){
    cmd3 << "select ReportExtendedDataIndex from reportExtendedData inner join reportData on reportExtendedData.ReportDataIndex=reportData.ReportDataIndex where reportData.timeindex =" << time_index[s];
    execute(cmd3.str());
    cmd3.str(std::string());  //clear out the string

    for(size_t r=0; r<m_results->data.size(); ++r){
      RVEDV_index.push_back(atoi(m_results->data[r][0].c_str()));
    }
  }


  execute("begin");

  std::stringstream cmd2;
  // reportData
  for(size_t r=0; r<time_index.size(); ++r){
    cmd2.str(std::string());  //clear out the string
    cmd2 << "delete from reportData where TimeIndex = " << time_index[r];
    execute(cmd2.str());
    //std::cout << cmd2.str() << std::endl;
    //print();
  }
  // reportExtendedData
  for(size_t r=0; r<RVEDV_index.size(); ++r){
    //std::stringstream cmd2;
    cmd2.str(std::string());  //clear out the string
    cmd2 << "delete from reportExtendedData where ReportExtendedDataIndex = " << RVEDV_index[r];
    execute(cmd2.str());
    //std::cout << cmd2.str() << std::endl;
    //print();
  }

  // Time
  for(size_t r=0; r<time_index.size(); ++r){
    //std::stringstream cmd2;
    cmd2.str(std::string());  //clear out the string
    cmd2 << "delete from Time where TimeIndex = " << time_index[r];
    execute(cmd2.str());
    //std::cout << cmd2.str() << std::endl;
    //print();
  }

  execute("commit");

  return true;
}
Beispiel #5
0
/// <summary>Initializes the quarter and year from a boost::gregorian::date.
/// </summary>
///
/// <remarks>Quarter is set to 0 for months 0-2, 1 for months 3-5, 2 for
/// months 6-8, or 3 for months 9-11.</remarks>
///
/// <param name="dateModyyr">The date to use.</param>
QtrYear::QtrYear( const boost::gregorian::date& dateModyyr ) :
quarterOfYear(static_cast<unsigned short>((dateModyyr.month() -
boost::date_time::Jan) / 3)),
yearPart(static_cast<unsigned short>(dateModyyr.year()))
{ }