PHP code example of devmakis / prodcalendar

1. Go to this page and download the library: Download devmakis/prodcalendar 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/ */

    

devmakis / prodcalendar example snippets


use Devmakis\ProdCalendar\Cache\FileJsonCache;
use Devmakis\ProdCalendar\Clients\XmlCalendarClient;
use Devmakis\ProdCalendar\Calendar;
use Devmakis\ProdCalendar\Country;

$cache = new FileJsonCache('FILE_PATH', 3600);
$client = new XmlCalendarClient(Country::RUSSIA, $cache);
$calendar = new Calendar($client);

$calendar->isNonWorking(new DateTime('01-01-2018'));
$calendar->isWeekend(new DateTime('01-01-2018'));
$calendar->isHoliday(new DateTime('01-01-2018'));
$calendar->isTransferredHoliday(new DateTime('24-03-2020'));

$calendar->isPreHoliday(new DateTime('22-02-2018'));

$dateBegin = new DateTime('31-01-2018');
$dateEnd = new DateTime('08-05-2018');
$countWorkingDays = $calendar->countWorkingDaysForPeriod($dateBegin, $dateEnd);
$countNonWorkingDays = $calendar->countNonWorkingDaysForPeriod($dateBegin, $dateEnd);

$year2018 = $calendar->getYear('2018');
$countWorkingDays = $year2018->countWorkingDays();
$countNonWorkingDays = $year2018->countNonWorkingDays();
$countWorkingDaysInMay = $year2018->getMonth('05')->countWorkingDays();