/**
  * promotion_date_range
  * returns the first and last chronologically ordered dates for a promotion (if different)
  *
  * @return string
  */
 public function promotion_date_range()
 {
     EE_Registry::instance()->load_helper('DTT_Helper');
     $start_date = $this->get_DateTime_object('PRO_start');
     $end_date = $this->get_DateTime_object('PRO_end');
     // if the promo starts at midnight on one day, and the promo ends at midnight on the very next day
     // (this also verifies that $dates are DateTime objects)
     if (EEH_DTT_Helper::dates_represent_one_24_hour_date($start_date, $end_date)) {
         return $start_date->format(EE_Datetime_Field::mysql_time_format) == '00:00:00' ? $this->get_i18n_datetime('PRO_start', $this->_dt_frmt) : $this->get_i18n_datetime('PRO_start');
     } else {
         if (!$start_date instanceof DateTime && $end_date instanceof DateTime) {
             return sprintf(_x('Ends: %s', 'Value is the end date for a promotion', 'event_espresso'), $this->get_i18n_datetime('PRO_end'));
         } else {
             if ($start_date instanceof DateTime && !$end_date instanceof DateTime) {
                 return sprintf(_x('Starts: %s', 'Value is the start date for a promotion', 'event_espresso'), $this->get_i18n_datetime('PRO_start'));
             } else {
                 if ($start_date instanceof DateTime && $end_date instanceof DateTime) {
                     return sprintf(_x('%s - %s', 'First value is start date and second value is end date in a date range.', 'event_espresso'), $this->get_i18n_datetime('PRO_start'), $this->get_i18n_datetime('PRO_end'));
                 } else {
                     return __('Ongoing Promotion', 'event_espresso');
                 }
             }
         }
     }
 }
 /**
  *  @since 4.7.0
  */
 public function test_dates_represent_one_24_hour_date()
 {
     $midnight_start = new DateTime('2015-01-25 00:00:00');
     $midnight_end = new DateTime('2015-01-26 00:00:00');
     $midday_start = new DateTime('2015-01-25 12:00:00');
     $midday_end = new DateTime('2015-01-26 12:00:00');
     $midnight_next_day = new DateTime('2015-01-27 00:00:00');
     //first test nulls
     $this->assertFalse(EEH_DTT_Helper::dates_represent_one_24_hour_date(null, $midnight_end));
     $this->assertFalse(EEH_DTT_Helper::dates_represent_one_24_hour_date($midnight_start, null));
     //test non midnights
     $this->assertFalse(EEH_DTT_Helper::dates_represent_one_24_hour_date($midnight_start, $midday_end));
     $this->assertFalse(EEH_DTT_Helper::dates_represent_one_24_hour_date($midday_start, $midnight_end));
     //test midnights but not 24 hours difference
     $this->assertFalse(EEH_DTT_Helper::dates_represent_one_24_hour_date($midnight_start, $midnight_next_day));
     //test correct range
     $this->assertTrue(EEH_DTT_Helper::dates_represent_one_24_hour_date($midnight_start, $midnight_end));
 }