From 167fcfcc37575b619273e8d9ff0f80dc38150332 Mon Sep 17 00:00:00 2001 From: arunsahijpal <arunsahijpal111@gmail.com> Date: Mon, 24 Mar 2025 18:26:12 +0530 Subject: [PATCH 1/2] Issue #3514939: Updated datetime help text. --- .../datetime/src/Hook/DatetimeHooks.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 core/modules/datetime/src/Hook/DatetimeHooks.php diff --git a/core/modules/datetime/src/Hook/DatetimeHooks.php b/core/modules/datetime/src/Hook/DatetimeHooks.php new file mode 100644 index 000000000000..17908c175c47 --- /dev/null +++ b/core/modules/datetime/src/Hook/DatetimeHooks.php @@ -0,0 +1,46 @@ +<?php + +namespace Drupal\datetime\Hook; + +use Drupal\Core\StringTranslation\StringTranslationTrait; +use Drupal\Core\Url; +use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Hook\Attribute\Hook; + +/** + * Hook implementations for datetime. + */ +class DatetimeHooks { + + use StringTranslationTrait; + + /** + * Implements hook_help(). + */ + #[Hook('help')] + public function help($route_name, RouteMatchInterface $route_match): ?string { + switch ($route_name) { + case 'help.page.datetime': + $output = ''; + $output .= '<h2>' . $this->t('About') . '</h2>'; + $output .= '<p>' . $this->t('The Datetime module provides a Date field that stores dates and times. It also provides the Form API elements <em>datetime</em> and <em>datelist</em> for use in programming modules. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI module help</a> pages for general information on fields and how to create and manage them.', [ + ':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), + ':field_ui' => \Drupal::moduleHandler()->moduleExists('field_ui') ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#', + ]) . '</p>'; + + $output .= '<h2>' . $this->t('Handling Timezones') . '</h2>'; + $output .= '<p>' . $this->t('Drupal stores all Date fields in UTC format. When a user enters a date, Drupal converts it to UTC based on their timezone. During display:') . '</p>'; + $output .= '<ul>'; + $output .= '<li>' . $this->t('<strong>Logged-in users</strong> see the date in their account’s timezone.') . '</li>'; + $output .= '<li>' . $this->t('<strong>Anonymous users</strong> see the date in the site’s default timezone.') . '</li>'; + $output .= '</ul>'; + + $output .= '<h2>' . $this->t('Configuring Display') . '</h2>'; + $output .= '<p>' . $this->t('Use the Date format settings to control how dates are displayed, ensuring clarity for multi-timezone audiences.') . '</p>'; + + return $output; + } + return NULL; + } + +} -- GitLab From 9384415ed712c0e8be1cf7f0fc56b4292a0a09bb Mon Sep 17 00:00:00 2001 From: arunsahijpal <arunsahijpal111@gmail.com> Date: Mon, 24 Mar 2025 18:32:48 +0530 Subject: [PATCH 2/2] Issue #3514939: Fixed phpcs. --- core/modules/datetime/src/Hook/DatetimeHooks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/modules/datetime/src/Hook/DatetimeHooks.php b/core/modules/datetime/src/Hook/DatetimeHooks.php index 17908c175c47..05688467c457 100644 --- a/core/modules/datetime/src/Hook/DatetimeHooks.php +++ b/core/modules/datetime/src/Hook/DatetimeHooks.php @@ -27,17 +27,17 @@ public function help($route_name, RouteMatchInterface $route_match): ?string { ':field' => Url::fromRoute('help.page', ['name' => 'field'])->toString(), ':field_ui' => \Drupal::moduleHandler()->moduleExists('field_ui') ? Url::fromRoute('help.page', ['name' => 'field_ui'])->toString() : '#', ]) . '</p>'; - + $output .= '<h2>' . $this->t('Handling Timezones') . '</h2>'; $output .= '<p>' . $this->t('Drupal stores all Date fields in UTC format. When a user enters a date, Drupal converts it to UTC based on their timezone. During display:') . '</p>'; $output .= '<ul>'; $output .= '<li>' . $this->t('<strong>Logged-in users</strong> see the date in their account’s timezone.') . '</li>'; $output .= '<li>' . $this->t('<strong>Anonymous users</strong> see the date in the site’s default timezone.') . '</li>'; $output .= '</ul>'; - + $output .= '<h2>' . $this->t('Configuring Display') . '</h2>'; $output .= '<p>' . $this->t('Use the Date format settings to control how dates are displayed, ensuring clarity for multi-timezone audiences.') . '</p>'; - + return $output; } return NULL; -- GitLab