boost::optional<IdfObject> ForwardTranslator::translateRunPeriodControlDaylightSavingTime( RunPeriodControlDaylightSavingTime & modelObject )
{
  IdfObject idfObject( openstudio::IddObjectType::RunPeriodControl_DaylightSavingTime);

  boost::optional<std::string> s;

  s = modelObject.getString(OS_RunPeriodControl_DaylightSavingTimeFields::StartDate);
  if( s )
  {
    std::string str = s.get();
    //auto index = str.find("5th", 0);
    //if (index != std::string::npos){
    //  str.replace(index, 3, "Last");
    //}

    idfObject.setString(RunPeriodControl_DaylightSavingTimeFields::StartDate, str);
  }

  s = modelObject.getString(OS_RunPeriodControl_DaylightSavingTimeFields::EndDate);
  if( s )
  {
    std::string str = s.get();
    //auto index = str.find("5th", 0);
    //if (index != std::string::npos){
    //  str.replace(index, 3, "Last");
    //}

    idfObject.setString(RunPeriodControl_DaylightSavingTimeFields::EndDate, str);
  }

  m_idfObjects.push_back(idfObject);

  return idfObject;
}
OptionalModelObject ReverseTranslator::translateRunPeriodControlDaylightSavingTime( const WorkspaceObject & workspaceObject )
{
  if( workspaceObject.iddObject().type() != IddObjectType::RunPeriodControl_DaylightSavingTime )
  {
     LOG(Error, "WorkspaceObject is not IddObjectType: RunPeriodControl_DaylightSavingTime");
     return boost::none;
  }

  RunPeriodControlDaylightSavingTime dst = m_model.getUniqueModelObject<RunPeriodControlDaylightSavingTime>();

  OptionalString s = workspaceObject.getString(RunPeriodControl_DaylightSavingTimeFields::StartDate);
  if(s){
    dst.setStartDate(*s);
  }

  s = workspaceObject.getString(RunPeriodControl_DaylightSavingTimeFields::EndDate);
  if(s) {
    dst.setEndDate(*s);
  }

 return dst;
}
boost::optional<IdfObject> ForwardTranslator::translateRunPeriodControlDaylightSavingTime( RunPeriodControlDaylightSavingTime & modelObject )
{
  IdfObject idfObject( openstudio::IddObjectType::RunPeriodControl_DaylightSavingTime);
  
  boost::optional<std::string> s;

  s = modelObject.getString(OS_RunPeriodControl_DaylightSavingTimeFields::StartDate);
  if( s )
  {
    idfObject.setString(RunPeriodControl_DaylightSavingTimeFields::StartDate, s.get());
  }

  s = modelObject.getString(OS_RunPeriodControl_DaylightSavingTimeFields::EndDate);
  if( s )
  {
    idfObject.setString(RunPeriodControl_DaylightSavingTimeFields::EndDate, s.get());
  }
  
  m_idfObjects.push_back(idfObject);

  return idfObject;
}
TEST_F(ModelFixture, RunPeriodControlDaylightSavingTime)
{
  Model model;
  RunPeriodControlDaylightSavingTime dst = model.getUniqueModelObject<RunPeriodControlDaylightSavingTime>();
  ASSERT_NO_THROW(dst.startDate()); // 2nd Sunday in March, assumed year is 2009
  EXPECT_EQ(8u, dst.startDate().dayOfMonth());
  EXPECT_EQ(MonthOfYear::Mar, dst.startDate().monthOfYear().value());

  ASSERT_NO_THROW(dst.endDate()); // 1st Sunday in November, assumed year is 2009
  EXPECT_EQ(1u, dst.endDate().dayOfMonth());
  EXPECT_EQ(MonthOfYear::Nov, dst.endDate().monthOfYear().value());
}