fixing date handling internationalisations on render.php

This commit is contained in:
Antoine M 2024-02-26 15:19:34 +01:00
parent 2d5c9b281c
commit 49a6ab5758
2 changed files with 38 additions and 8 deletions

View File

@ -1,5 +1,6 @@
<?php
$press_kit_datas = get_field('press_kit_datas', 'option');
if (!function_exists('getRessourceIcon')) {
@ -47,11 +48,25 @@ if (!function_exists('getRessourceTypeName')) {
$ressourceType = $data['mime_type'];
$ressourceIcon = getRessourceIcon($ressourceType);
setlocale(LC_TIME, 'fr_FR');
$timestamp = strtotime($data['modified']);
$formatted_date = strftime("%B %Y", $timestamp);
$currentLanguage = apply_filters('wpml_current_language', NULL);
$locale = $currentLanguage === "fr" ? 'fr_FR' : 'nl_NL';
$timezone = 'Europe/Paris';
$pattern = 'MMMM yyyy';
$dateTime = new DateTime($data['modified']);
$formatter = new IntlDateFormatter(
$locale,
IntlDateFormatter::NONE, // Pas besoin de format de date intégré
IntlDateFormatter::NONE, // Pas besoin de format de temps
$timezone,
IntlDateFormatter::GREGORIAN,
$pattern // Utiliser le format personnalisé ici
);
$postModifiedDate = $formatter->format($dateTime);
?>
<li class="homegrade-blocks-kit-presse__press-ressource">
<div class="homegrade-blocks-kit-presse__ressource-typename">
<div class="homegrade-blocks-kit-presse__ressource-icon">
@ -60,7 +75,7 @@ if (!function_exists('getRessourceTypeName')) {
<p class="homegrade-blocks-kit-presse__ressource-title"><?php echo $data['title'] ?></p>
</div>
<p class="homegrade-blocks-kit-presse__ressource-type"><?php echo getRessourceTypeName($data['subtype']) ?></p>
<p class="homegrade-blocks-kit-presse__ressource-date"><?php echo $formatted_date ?></p>
<p class="homegrade-blocks-kit-presse__ressource-date"><?php echo $postModifiedDate ?></p>
<a class="homegrade-blocks-kit-presse__ressource-download cta cta--secondary cta--button" href="<?php echo $data['url'] ?>" download><?php echo __('Télécharger', "homegrade-blocks__texte-fonctionnel") ?></a>
</li>

View File

@ -1,5 +1,6 @@
<?php
$press_kit_datas = get_field('press_kit_datas', 'option');
if (!function_exists('getRessourceIcon')) {
@ -47,11 +48,25 @@ if (!function_exists('getRessourceTypeName')) {
$ressourceType = $data['mime_type'];
$ressourceIcon = getRessourceIcon($ressourceType);
setlocale(LC_TIME, 'fr_FR');
$timestamp = strtotime($data['modified']);
$formatted_date = strftime("%B %Y", $timestamp);
$currentLanguage = apply_filters('wpml_current_language', NULL);
$locale = $currentLanguage === "fr" ? 'fr_FR' : 'nl_NL';
$timezone = 'Europe/Paris';
$pattern = 'MMMM yyyy';
$dateTime = new DateTime($data['modified']);
$formatter = new IntlDateFormatter(
$locale,
IntlDateFormatter::NONE, // Pas besoin de format de date intégré
IntlDateFormatter::NONE, // Pas besoin de format de temps
$timezone,
IntlDateFormatter::GREGORIAN,
$pattern // Utiliser le format personnalisé ici
);
$postModifiedDate = $formatter->format($dateTime);
?>
<li class="homegrade-blocks-kit-presse__press-ressource">
<div class="homegrade-blocks-kit-presse__ressource-typename">
<div class="homegrade-blocks-kit-presse__ressource-icon">
@ -60,7 +75,7 @@ if (!function_exists('getRessourceTypeName')) {
<p class="homegrade-blocks-kit-presse__ressource-title"><?php echo $data['title'] ?></p>
</div>
<p class="homegrade-blocks-kit-presse__ressource-type"><?php echo getRessourceTypeName($data['subtype']) ?></p>
<p class="homegrade-blocks-kit-presse__ressource-date"><?php echo $formatted_date ?></p>
<p class="homegrade-blocks-kit-presse__ressource-date"><?php echo $postModifiedDate ?></p>
<a class="homegrade-blocks-kit-presse__ressource-download cta cta--secondary cta--button" href="<?php echo $data['url'] ?>" download><?php echo __('Télécharger', "homegrade-blocks__texte-fonctionnel") ?></a>
</li>