MCPcopy Create free account
hub / github.com/NatLabRockies/OpenStudio / containsDate

Method containsDate

src/model/ScheduleRule.cpp:414–470  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

TEST_FFunction · 0.80

Calls 14

startDateMethod · 0.95
endDateMethod · 0.95
specificDatesMethod · 0.95
applySundayMethod · 0.95
applyMondayMethod · 0.95
applyTuesdayMethod · 0.95
applyWednesdayMethod · 0.95
applyThursdayMethod · 0.95
applyFridayMethod · 0.95
applySaturdayMethod · 0.95
istringEqualFunction · 0.85
dayOfWeekMethod · 0.80

Tested by 1

TEST_FFunction · 0.64