PHP code example of intragile / laravel-hungarian-workdays
1. Go to this page and download the library: Download intragile/laravel-hungarian-workdays library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
intragile / laravel-hungarian-workdays example snippets
use IntrAgile\HungarianWorkdays\Calendar;
$calendar = new Calendar;
$calendar->isWorkday(new DateTimeImmutable('2026-03-16')); // true
$calendar->isWorkday(new DateTimeImmutable('2026-01-02')); // false, moved rest day
$calendar->isWorkday(new DateTimeImmutable('2026-01-10')); // true, worked Saturday
$calendar->dayType(new DateTimeImmutable('2026-08-20')); // DayType::PublicHoliday
$calendar->holiday(new DateTimeImmutable('2026-08-20')); // Holiday::StStephensDay
$calendar->nextWorkday(new DateTimeImmutable('2026-03-13')); // 2026-03-16 00:00
$calendar->previousWorkday(new DateTimeImmutable('2026-03-16')); // 2026-03-13 00:00
$calendar->addWorkdays(new DateTimeImmutable('2026-03-13'), 5); // 2026-03-20 00:00
$calendar->workdaysBetween($from, $to); // both ends
'schedules' => [
2027 => [
'source' => 'Title of the 2027 work schedule decree', // fill in
'url' => 'https://njt.jog.gov.hu/...', // fill in
'rest_days' => [], // weekdays that became rest days, e.g. '2027-05-14'
'worked_saturdays' => [], // Saturdays worked in exchange, e.g. '2027-05-22'
],
],
use IntrAgile\HungarianWorkdays\Calendar;
use IntrAgile\HungarianWorkdays\Schedule;
use IntrAgile\HungarianWorkdays\ScheduleRepository;
$calendar = new Calendar(
ScheduleRepository::bundled()->with(Schedule::fromArray(2027, [
'source' => 'Title of the 2027 work schedule decree',
'url' => 'https://njt.jog.gov.hu/...',
'rest_days' => [],
'worked_saturdays' => [],
])),
);
$calendar = (new Calendar)->assumingNoTransfers();
use IntrAgile\HungarianWorkdays\Laravel\Facades\Workdays;
Workdays::isWorkday(now());
Workdays::addWorkdays(now(), 8);