You are here

private function SmartDateRecurrenceFormatter::findNextInstanceByDay in Smart Date 3.3.x

Same name and namespace in other branches
  1. 3.1.x modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php \Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::findNextInstanceByDay()
  2. 3.2.x modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php \Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::findNextInstanceByDay()
  3. 3.4.x modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php \Drupal\smart_date_recur\Plugin\Field\FieldFormatter\SmartDateRecurrenceFormatter::findNextInstanceByDay()

Helper function to find the next instance from now in a provided range.

1 call to SmartDateRecurrenceFormatter::findNextInstanceByDay()
SmartDateRecurrenceFormatter::viewElements in modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php

File

modules/smart_date_recur/src/Plugin/Field/FieldFormatter/SmartDateRecurrenceFormatter.php, line 297

Class

SmartDateRecurrenceFormatter
Plugin for a recurrence-optimized formatter for 'smartdate' fields.

Namespace

Drupal\smart_date_recur\Plugin\Field\FieldFormatter

Code

private function findNextInstanceByDay(array $dates, $today) {
  $next_index = -1;
  foreach ($dates as $index => $date) {
    if ($date >= $today) {
      $next_index = $index;
      break;
    }
  }
  return $next_index;
}