36 lines
1022 B
PHP
36 lines
1022 B
PHP
<?php
|
|
|
|
namespace OCA\Gestion\Helpers;
|
|
|
|
use DateTime;
|
|
use DateTimeZone;
|
|
use Exception;
|
|
|
|
class DateHelpers
|
|
{
|
|
public static function isWeekend(string $dateString): bool
|
|
{
|
|
try {
|
|
$date = new DateTime($dateString);
|
|
$dayOfWeek = $date->format('N');
|
|
return in_array($dayOfWeek, [6, 7]);
|
|
} catch (Exception $e) {
|
|
// Handle invalid date strings
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static function GetDateWithFormatDayAndMonthPlainString(string $date){
|
|
$dateTime = new DateTime($date);
|
|
$formattedDate = $dateTime->format('d F');
|
|
$formattedDate = str_replace(
|
|
array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'),
|
|
array('JANVIER', 'FEVRIER', 'MARS', 'AVRIL', 'MAI', 'JUIN', 'JUILLET', 'AOUT', 'SEPTEMBRE', 'OCTOBRE', 'NOVEMBRE', 'DECEMBRE'),
|
|
$formattedDate
|
|
);
|
|
|
|
return $formattedDate;
|
|
}
|
|
|
|
}
|