module

meta_base.module
/**
 * Implements hook_form_FORM_ID_alter().
 *
 * Replace ugly "Field cannot be empty" error message for comments.
 */
function meta_base_form_comment_story_comment_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  array_unshift($form['#validate'], '_meta_base_comment_validate');
  $form['comment_body']['widget']['#required'] = false;
  $form['comment_body']['widget'][0]['#required'] = false;
}

/**
 * Custom validation for better error message on empty comments.
 */
function _meta_base_comment_validate(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
  if (empty($form_state->getValue('comment_body')[0]['value'])) {
    $form_state->setErrorByName('comment_body', t('Please enter a comment. An empty comment cannot be saved.'));
  }
}
iftra_group_breadcrumbs.module

/**
 * Implements hook_theme_registry_alter().
 */
function hook_theme_registry_alter(&$theme_registry) {
  // Kill the gin breadcrumb preprocessor, since we do our own backend
  // breadcrumb logic.
  foreach ($theme_registry['breadcrumb']['preprocess functions'] as $key => $value) {
    if ($value == 'gin_preprocess_breadcrumb') {
      unset($theme_registry['breadcrumb']['preprocess functions'][$key]);
    }
  }
}
17.08.2022 | Pascal Crott

iftra_group_breadcrumbs.module

my_module.module
// Get DrupalDateTime object with current date & time (timezone from system is used).
$current_date = new DrupalDateTime();

// Get DrupalDateTime object with the value from a field of type date (timezone from system is used).
$deadline = $entity->field_date->date;

// Change timezone to 'UTC' (just for demo/devbit purpose).
$freelancer_dl->setTimezone(new DateTimeZone('UTC'));
$current_date->setTimezone(new DateTimeZone('UTC'));

// Format DrupalDateTime object (just for demo/devbit purpose).
$freelancer_dl->format(\Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::DATETIME_STORAGE_FORMAT);
$current_date->format(\Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface::DATETIME_STORAGE_FORMAT);

// Modify DrupalDateTime object.
$deadline->modify('-2 Days');

// You can compare the DrupalDateTime objects.
if ($deadline <= $current_date) {
  //...do something...
}