Skip to content
This repository has been archived by the owner on Jul 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1985 from anprok/YGO-24
Browse files Browse the repository at this point in the history
[YGO-24] Carnation theme fixes for event page
  • Loading branch information
podarok committed Apr 6, 2020
2 parents a5197d6 + a952311 commit 830efa9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 12 deletions.
Expand Up @@ -6,6 +6,7 @@
*/

use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface;
use Drupal\node\Entity\Node;
use Drupal\Core\Link;
use Drupal\Core\Url;
Expand Down Expand Up @@ -55,10 +56,10 @@ function openy_node_event_preprocess_field__node__field_event_location__event(&$
if (empty($datesField[0])) {
return;
}
$timezone = drupal_get_user_timezone();
$startDt = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $datesField[0]['value'], DATETIME_STORAGE_TIMEZONE);
$timezone = date_default_timezone_get();
$startDt = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $datesField[0]['value'], DateTimeItemInterface::STORAGE_TIMEZONE);
$startDt->setTimezone(timezone_open($timezone));
$endDt = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $datesField[0]['end_value'], DATETIME_STORAGE_TIMEZONE);
$endDt = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $datesField[0]['end_value'], DateTimeItemInterface::STORAGE_TIMEZONE);
$endDt->setTimezone(timezone_open($timezone));
$datesInfo = [
'date_start' => $startDt,
Expand Down Expand Up @@ -150,18 +151,22 @@ function openy_node_event_preprocess_node(&$variables) {
if ($variables['view_mode'] == 'teaser' && $variables['node']->getType() == 'event') {
// Get dates.
$datesField = $variables['node']->get('field_event_dates')->getValue();
$timezone = drupal_get_user_timezone();
$startDt = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $datesField[0]['value'], DATETIME_STORAGE_TIMEZONE);
$timezone = date_default_timezone_get();

$startDt = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $datesField[0]['value'], DateTimeItemInterface::STORAGE_TIMEZONE);
$startDt->setTimezone(timezone_open($timezone));
$endDt = DrupalDateTime::createFromFormat(DATETIME_DATETIME_STORAGE_FORMAT, $datesField[0]['end_value'], DATETIME_STORAGE_TIMEZONE);

$endDt = DrupalDateTime::createFromFormat(DateTimeItemInterface::DATETIME_STORAGE_FORMAT, $datesField[0]['end_value'], DateTimeItemInterface::STORAGE_TIMEZONE);
$endDt->setTimezone(timezone_open($timezone));

$formatted_start_date = $startDt->format('g:i a');
$formatted_end_date = $endDt->format('g:i a');
// Display month and day if the event lasts several days.
if ($startDt->format("Y-m-d") != $endDt->format("Y-m-d")) {
$formatted_start_date = $startDt->format(('M j, g:i a') );
$formatted_end_date = $endDt->format(('M j, g:i a') );
}

$variables['content']['event_converted_dates'] = [
'date_start' => $formatted_start_date,
'date_end' => $formatted_end_date,
Expand Down
Expand Up @@ -5,8 +5,8 @@
*
* Available variables:
* - info: The info array with access to event date info.
* - info.date_start will return formated "j M g:i a" event start date.
* - info.date_end will return formated "g:i a" event end date.
* - info.date_start will return event start date.
* - info.date_end will return event end date.
* - atc: The atc array of additional calendar info.
* - atc_date_start will return formated "Y-m-d H:i:s" event start date.
* - atc_date_end will return formated "Y-m-d H:i:s" event end date.
Expand Down
Expand Up @@ -15,7 +15,7 @@
*/
#}
<div class="d-inline-block w-100">
<h5><i class="far fa-question-circle text-gray-300"></i>{{ 'Contact Information'|t }}</h5>
<h5><i class="far fa-question-circle text-gray-300"></i> {{ 'Contact Information'|t }}</h5>

{% if info.phone is not empty %}
<div class="contact-phone"><i class="fa fa-phone text-gray-300"></i> {{ info.phone }}</div>
Expand Down
Expand Up @@ -5,8 +5,8 @@
*
* Available variables:
* - info: The info array with access to event date info.
* - info.date_start will return formated "j M g:i a" event start date.
* - info.date_end will return formated "g:i a" event end date.
* - info.date_start will return event start date.
* - info.date_end will return event end date.
* - atc: The atc array of additional calendar info.
* - atc_date_start will return formated "Y-m-d H:i:s" event start date.
* - atc_date_end will return formated "Y-m-d H:i:s" event end date.
Expand All @@ -23,7 +23,7 @@
#}
<div class="d-inline-block w-100 pb-4 mb-4 border-light border-bottom">
<h5><i class="far fa-clock text-gray-300"></i> {{ 'Event Details'|t }}</h5>
<div class="date-start">{{ info.date_start }} - {{ info.date_end }}</div>
<div class="date-start">{{ info.date_start|date('M j, g:i a') }} - {{ info.date_end|date('M j, g:i a') }}</div>
<div class="addtocalendar atc-style-blue mt-2">
<var class="atc_event">
<var class="atc_date_start">{{ atc.atc_date_start }}</var>
Expand Down

0 comments on commit 830efa9

Please sign in to comment.