| 412 | } |
| 413 | |
| 414 | bool ScheduleRule_Impl::containsDate(const openstudio::Date& date) { |
| 415 | bool result = false; |
| 416 | |
| 417 | // need to check or adjust assumed base year on input date? |
| 418 | |
| 419 | boost::optional<std::string> dateSpecificationType = this->getString(OS_Schedule_RuleFields::DateSpecificationType, true); |
| 420 | OS_ASSERT(dateSpecificationType); |
| 421 | if (istringEqual("DateRange", *dateSpecificationType)) { |
| 422 | boost::optional<openstudio::Date> startDate = this->startDate(); |
| 423 | OS_ASSERT(startDate); |
| 424 | boost::optional<openstudio::Date> endDate = this->endDate(); |
| 425 | OS_ASSERT(endDate); |
| 426 | if (*startDate <= *endDate) { |
| 427 | result = ((date >= *startDate) && (date <= *endDate)); |
| 428 | } else { |
| 429 | result = ((date >= *startDate) || (date <= *endDate)); |
| 430 | } |
| 431 | } else { |
| 432 | std::vector<openstudio::Date> specificDates = this->specificDates(); |
| 433 | for (const openstudio::Date& specificDate : specificDates) { |
| 434 | if (specificDate == date) { |
| 435 | result = true; |
| 436 | break; |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | if (result) { |
| 442 | switch (date.dayOfWeek().value()) { |
| 443 | case DayOfWeek::Sunday: |
| 444 | result = this->applySunday(); |
| 445 | break; |
| 446 | case DayOfWeek::Monday: |
| 447 | result = this->applyMonday(); |
| 448 | break; |
| 449 | case DayOfWeek::Tuesday: |
| 450 | result = this->applyTuesday(); |
| 451 | break; |
| 452 | case DayOfWeek::Wednesday: |
| 453 | result = this->applyWednesday(); |
| 454 | break; |
| 455 | case DayOfWeek::Thursday: |
| 456 | result = this->applyThursday(); |
| 457 | break; |
| 458 | case DayOfWeek::Friday: |
| 459 | result = this->applyFriday(); |
| 460 | break; |
| 461 | case DayOfWeek::Saturday: |
| 462 | result = this->applySaturday(); |
| 463 | break; |
| 464 | default: |
| 465 | OS_ASSERT(false); |
| 466 | } |
| 467 | } |
| 468 | |
| 469 | return result; |
| 470 | } |
| 471 | |