Custom entity datetime field in calendar I created an entity in a module, using code. I generated skeletons with drupal console generate:entity:content (without bundles), and then added a datetime field to my TestFieldEntityItem.php, in baseFieldDefinitions().

$fields['test_date'] = BaseFieldDefinition::create('datetime')
  -&gt;setLabel(t('Test date'))
  -&gt;setDescription(t('Test.'))
  -&gt;setRevisionable(TRUE)
  -&gt;setSettings([
    'datetime_type' =&gt; 'date'
  ])
  -&gt;setDefaultValue('')
  -&gt;setDisplayOptions('view', [
    'label' =&gt; 'above',
    'type' =&gt; 'datetime_default',
    'settings' =&gt; [
      'format_type' =&gt; 'medium',
    ],
    'weight' =&gt; 14,
  ])
  -&gt;setDisplayOptions('form', [
    'type' =&gt; 'datetime_default',
    'weight' =&gt; 14,
  ])
  -&gt;setDisplayConfigurable('form', TRUE)
  -&gt;setDisplayConfigurable('view', TRUE);


I installed my module, cleared the cache, reinstalled calendar and calendar_datetime modules, but when I try to add a view from a template, like the calendar module suggests, I can't see any template matching my datetime field.

If I create a datetime field on this entity through the UI, it appears in view templates. What am I missing?

Inspecting the calendar code, I found the function that search datetime fields, in ViewsFieldTemplate.php.
This function finds my field, but the field_info does not match isDateField() because of the argument property.

isDateField() wants 'datetime' as argument ID.

protected function isDateField($field_info) {
  if (!empty($field_info['field']['id']) &amp;&amp; $field_info['field']['id'] == 'field') {
    if (!empty($field_info['argument']['id']) &amp;&amp; $field_info['argument']['id'] == 'date') {
      return TRUE;
    }
  }
  return FALSE;
}


My field_info argument is 'string'.

array (size=7)
  'title' =&gt; ...
  'help' =&gt; ...
  'field' =&gt; 
      'id' =&gt; string 'field' (length=5)
  'argument' =&gt; 
      'id' =&gt; string 'string' (length=6)
  'filter' =&gt; 
      'id' =&gt; string 'string' (length=6)
  'sort' =&gt; 
      'id' =&gt; string 'standard' (length=8)
  'entity field' =&gt; string 'test_date' (length=4)


So thanks to @4k4 answer, I tried to do the same as the working date field, and I created my own EntityViewsData (I tried hook_views_data_alter() first but the field was not present in input data)

namespace Drupal\kabukis_tests\Entity;
use Drupal\views\EntityViewsData;

class TestEntityViewsData extends EntityViewsData {
  public function getViewsData() {
    $additionalData = [
      'test_date' =&gt; [
        'title' =&gt; new TranslatableMarkup('Birth date'),
        'help' =&gt; new TranslatableMarkup('Birth date'),
        'field' =&gt; [ 'id' =&gt; 'field' ],
        'argument' =&gt; [ 'id' =&gt; 'date' ],
        'filter' =&gt; [ 'id' =&gt; 'date' ],
        'sort' =&gt; [ 'id' =&gt; 'date' ],
        'entity field' =&gt; 'test_date',
      ]
    ];
    $data['test_field_entity_field_data'] = array_merge($data['test_field_entity_field_data'], $additionalData);
    return $data;
  }
}


Now, the field appears in views template list ! However, the generated view is not working, I get the following error :


  \Drupal\calendar\Plugin\views\style\CalendarStyle: A calendar date argument is required when using the calendar style, but it is missing or is not using the default date.
EntityViewsData provides the information for views for entity types, so that they are included in views. For datetime basefields this is not working at the moment, because of this issue https://www.drupal.org/node/2489476. So you need to provide the data in a hook_views_data or by extending EntityViewsData. From the documentation:


  
  argument: Specifies a handler to make it available to Views as an   argument, or contextual filter as it is known in the UI.
  


https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php/function/hook_views_data/8.3.x

You've mentioned that you have a working example if you use a field configured in UI, so you could try to copy the views data.