protected function viewValue(FieldItemInterface $item) {
    $field = $item->getFieldDefinition();
    if ($field->get('field_type') == 'daterange') {
      $value = $item->start_date;
    }
    else {
      $value = $item->date;
    }
    $build = [
      '#theme' => 'calendar_item_date',
      '#datetime' => $value,
      '#attached' => [
        'library' => [
          'govcms8_calendar_item/calendar_item',
        ],
      ],
    ];
    return $build;
  }
protected function viewValue(FieldItemInterface $item) {
    $field = $item->getFieldDefinition();
    if ($field->get('field_type') == 'daterange') {
      $value = $item->start_date;
    }
    else {
      $value = $item->date;
    }
    $build = [
      '#theme' => 'calendar_item_date',
      '#datetime' => $value,
      '#attached' => [
        'library' => [
          'govcms8_calendar_item/calendar_item',
        ],
      ],
    ];
    return $build;
  }
protected function viewValue ( FieldItemInterface $ item ) { $ field = $ item -> getFieldDefinition ( ) ; if ( $ field -> get ( 'field_type' ) == 'daterange' ) { $ value = $ item -> start_date ; } else { $ value = $ item -> date ; } $ build = [ '#theme' => 'calendar_item_date' , '#datetime' => $ value , '#attached' => [ 'library' => [ 'govcms8_calendar_item/calendar_item' , ] , ] , ] ; return $ build ; }
Generate the output appropriate for one field item.

@param \Drupal\Core\Field\FieldItemInterface $item
One field item.

@return array
The textual output generated.
Generate the output appropriate for one field item .