| 470 | } |
| 471 | |
| 472 | std::vector<bool> ScheduleRule_Impl::containsDates(const std::vector<openstudio::Date>& dates) { |
| 473 | unsigned N = dates.size(); |
| 474 | std::vector<bool> result(N, false); |
| 475 | |
| 476 | // need to check or adjust assumed base year on input date? |
| 477 | |
| 478 | boost::optional<std::string> dateSpecificationType = this->getString(OS_Schedule_RuleFields::DateSpecificationType, true); |
| 479 | OS_ASSERT(dateSpecificationType); |
| 480 | if (istringEqual("DateRange", *dateSpecificationType)) { |
| 481 | boost::optional<openstudio::Date> startDate = this->startDate(); |
| 482 | OS_ASSERT(startDate); |
| 483 | boost::optional<openstudio::Date> endDate = this->endDate(); |
| 484 | OS_ASSERT(endDate); |
| 485 | if (*startDate <= *endDate) { |
| 486 | for (unsigned i = 0; i < N; ++i) { |
| 487 | result[i] = ((dates[i] >= *startDate) && (dates[i] <= *endDate)); |
| 488 | } |
| 489 | } else { |
| 490 | for (unsigned i = 0; i < N; ++i) { |
| 491 | result[i] = ((dates[i] >= *startDate) || (dates[i] <= *endDate)); |
| 492 | } |
| 493 | } |
| 494 | } else { |
| 495 | std::vector<openstudio::Date> specificDates = this->specificDates(); |
| 496 | for (unsigned i = 0; i < N; ++i) { |
| 497 | for (const openstudio::Date& specificDate : specificDates) { |
| 498 | if (specificDate == dates[i]) { |
| 499 | result[i] = true; |
| 500 | break; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | |
| 506 | bool applySunday = this->applySunday(); |
| 507 | bool applyMonday = this->applyMonday(); |
| 508 | bool applyTuesday = this->applyTuesday(); |
| 509 | bool applyWednesday = this->applyWednesday(); |
| 510 | bool applyThursday = this->applyThursday(); |
| 511 | bool applyFriday = this->applyFriday(); |
| 512 | bool applySaturday = this->applySaturday(); |
| 513 | |
| 514 | for (unsigned i = 0; i < N; ++i) { |
| 515 | if (result[i]) { |
| 516 | switch (dates[i].dayOfWeek().value()) { |
| 517 | case DayOfWeek::Sunday: |
| 518 | result[i] = applySunday; |
| 519 | break; |
| 520 | case DayOfWeek::Monday: |
| 521 | result[i] = applyMonday; |
| 522 | break; |
| 523 | case DayOfWeek::Tuesday: |
| 524 | result[i] = applyTuesday; |
| 525 | break; |
| 526 | case DayOfWeek::Wednesday: |
| 527 | result[i] = applyWednesday; |
| 528 | break; |
| 529 | case DayOfWeek::Thursday: |
no test coverage detected