From 34fd8b57ff36d96fae9936b461f91eb83638deaf Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 19 Jan 2025 16:46:45 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(date):=20add=20a=20tool=20to=20pre?= =?UTF-8?q?tty=20print=20archive=20dates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bl-kernel/helpers/date.class.php | 33 ++++++++++++++++++++++++++++++++ bl-languages/fr_FR.json | 1 + 2 files changed, 34 insertions(+) diff --git a/bl-kernel/helpers/date.class.php b/bl-kernel/helpers/date.class.php index 843905a8..6886ea43 100644 --- a/bl-kernel/helpers/date.class.php +++ b/bl-kernel/helpers/date.class.php @@ -2,6 +2,21 @@ class Date { + private const MONTHS = [ + "01" => "January", + "02" => "February", + "03" => "March", + "04" => "April", + "05" => "May", + "06" => "June", + "07" => "July", + "08" => "August", + "09" => "September", + "10" => "October", + "11" => "November", + "12" => "December" + ]; + // Returns string with the date translated // Example: $date = 'Mon, 27th March' > 'Lun, 27th Marzo' public static function translate($date) @@ -127,4 +142,22 @@ class Date { return $tmp; } + + private static function getMonthName($month) { + return isset(self::MONTHS[$month]) ? self::MONTHS[$month] : null; + } + + public static function prettyArchiveDate($date) { + global $L; + $explodedDate = explode("-", $date); + try { + if (sizeof($explodedDate) > 2) { + return $date; + } else { + return self::translate(self::getMonthName($explodedDate[1])." ".$explodedDate[0]); + } + } catch (Exception $e) { + return $L->g("Invalid Date"); + } + } } diff --git a/bl-languages/fr_FR.json b/bl-languages/fr_FR.json index 5230dfa6..72192ee8 100644 --- a/bl-languages/fr_FR.json +++ b/bl-languages/fr_FR.json @@ -166,6 +166,7 @@ "current-format": "Format actuel", "version": "Version", "author": "Auteur", + "authors": "Auteurs", "activate": "Activer", "deactivate": "Désactiver", "edit-category": "Modifier la catégorie",