Giter Club home page Giter Club logo

is-day-off's Introduction

IsDayOf

Latest Version Downloads Documentation

PHP SDK for isdayof.ru

Instalation

composer require phptcloud/isdayoff-sdk

After install

You can check the work of the scripts in the "Examples" folder. ;)

Simple example

require_once __DIR__ . '/../vendor/autoload.php';

use isDayOff\Client\IsDayOff;

$client = new IsDayOff();

$date = new DateTime('now');
$result = $client->date()->isDayOff($date);

if($result) {
    echo 'is day off.';
} else {
    echo 'working day.';
}

Filters

// Countries
isDayOff\Filters\UkraineFilter
isDayOff\Filters\RussianFilter
isDayOff\Filters\KazakhstanFilter
isDayOff\Filters\BelorusFilter
isDayOff\Filters\UnitedStatesFilter
isDayOff\Filters\UzbekistanFilter
isDayOff\Filters\TurkeyFilter

// Additional
isDayOff\Filters\CovidFilter
isDayOff\Filters\PreHolidayFilter

Filters examples

/**
 * New filter collection
 */
$filters = new FiltersCollection();
$filters->addOne(new UkraineFilter());

$client->date()->setFilters($filters);
$date = new DateTime('2019/01/01');

$result = $client->date()->getDataPerMonth($date);

print_r($result);

is-day-off's People

Contributors

phptcloud avatar michael-zorin avatar alnidok avatar

Stargazers

Hasmik avatar Jean Ferreira dos Santos avatar Paul Koop avatar Hamada avatar chebupelka avatar Abdulkareem seefUldeen avatar Maria-Eduarda-Leal avatar  avatar  avatar Ömer Arpacı avatar  avatar zhenrong-wang avatar 石見 仁志 avatar  avatar Dmitrii Shcherbakov avatar lebedevsergey avatar Webcore avatar Mikhail avatar  avatar  avatar Vladimir 'def' Titov. avatar Vladislav Shirokikh avatar Alex Babintsev avatar Maxim Sluysarenko avatar

Watchers

 avatar

is-day-off's Issues

Installation error

composer require phptcloud/isdayoff-sdk               
                                                                                                                                                            
  [InvalidArgumentException]                                                                                                                                               
  Could not find a version of package phptcloud/isdayoff-sdk matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desire  
  d stability.                                                                                                                                                             

I think you need to add the tag to the repository

Ошибки после обновления до v1.0.1 на версиях php<7.4

Версия 1.0.1 предполагает использование типизированных свойств в классах (например), поддержка которых появилась в php7.4 - https://www.php.net/manual/ru/migration74.new-features.php#migration74.new-features.core.typed-properties.

Т.к. сейчас в composer.json нет ограничения на версию, значит после минорного обновления composer-пакета все, у кого версия php ниже, получат ошибки!

syntax error, unexpected 'DateService' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)

Собственно это начало происходить после того, как на https://packagist.org/packages/phptcloud/isdayoff-sdk версия пакета обновилась до 1.0.1 (2022-03-21 03:26 UTC), странно почему до сих пор не было issue :)

На будущее:

  1. Изменения, ломающие обратную совместимость (в т.ч. переход на новые версии языка) должны происходить в мажорных версиях пакета, тогда стандартный "phptcloud/isdayoff-sdk": "^1.0", не будет обновлять до версий 2.0 и т.д. (подробнее).
  2. Всегда указывать версию языка и все зависимости, необходимые для работы пакета, в composer.json (секция require). Тогда composer будет ругаться при попытке обновить пакет, если что-то не так. А сейчас все успешно установится, и о проблеме станет известно лишь по ParseError.

Update required guzzlehttp/guzzle version to ^7.0

The library requires outdated guzzlehttp/guzzle of outdated ^6.0 version though the current guzzlehttp/guzzle version is 7.5.0.
It would be nice to update the required guzzlehttp/guzzle version to ^7.0

Долгий ответ сервера

Спасибо за труды, однако попробовав библиотеку обнаружил, что ответ составляет около 3 секунд (пробовал вызывать для одной недели) к сожалению это неприемлимо. Вот приблизительно как я это делал:

//configure dayOffService
$dayOffClient = new IsDayOff();
$filters = new FiltersCollection();
$filter = self::IS_DAY_OF_COUNTRY_FILTERS[$this->countryId] ?? self::IS_DAY_OF_DEFAULT_FILTER;
$filters->addOne(new $filter());
$dateTime = new \DateTime();

foreach ($data as $timeDay => $rowsData) {
  $dataHead['isDayOff'][$timeDay] = $dayOffClient->date()->isDayOff($dateTime->setTimestamp($timeDay));
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.