24 lines
452 B
PHP
24 lines
452 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;
|
|
}
|
|
}
|
|
|
|
}
|