2017 © Pedro Peláez
 

library swiss-off

PHP Library used to know if a day is off in a given Swiss Canton

image

dominiquevienne/swiss-off

PHP Library used to know if a day is off in a given Swiss Canton

  • Wednesday, June 21, 2017
  • by dvienne
  • Repository
  • 1 Watchers
  • 2 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

swissOff

Library used to know if a day is off in a given Swiss Canton, (*1)

Installation

Go to you project root directory and use composer using this command, (*2)

composer require dominiquevienne/swiss-off

Then create your application bootstrap using this kind of code, (*3)

<?php
require __DIR__ . '/vendor/autoload.php';

$oCanton  = new Dominiquevienne\SwissOff\Canton();
echo date('Y-m-d H:i:s',$oCanton->getNextDayOffByCanton('VD'));

Manual installation

  • Download latest stable release on Github
  • Uncompress the downloaded file
  • Place content into your project
  • Use similar code to load object
<?php
require __DIR__ . '/swiss-off/src/SwissOff.php';
require __DIR__ . '/swiss-off/src/Canton.php';

$oCanton  = new Dominiquevienne\SwissOff\Canton();
echo date('Y-m-d H:i:s',$oCanton->getNextDayOffByCanton('VD'));

Laravel

Using swissOff in Laravel is as simple as a, (*4)

composer require dominiquevienne/swiss-off

and add the following lines in your class, (*5)

<?php
use Dominiquevienne\SwissOff\Canton;

class yourController {
  public function show() {
    /** some code of yours */
    $oCanton  = new Canton();
    return date('Y-m-d H:i:s',$oCanton->getNextDayOffByCanton('VD'));
  }
}

Available functions

Note: time is always given to functions and returned as a timestamp., (*6)

Canton

getDaysOffByCantonAndTime($canton, $time = null)

This function will return an array containing every day off of the year of the given time for the specified canton (two letters code)., (*7)

If no time is given, current time will be used., (*8)

getDaysOffNames()

This function will return an array containing all days off machine name (eg. Christmas, Berchtold, ...), (*9)

getCantonsByDayOffName($dayOffName)

This function will return an array containing all cantons that are off for this day off., (*10)

getNextDayOffByCanton($canton, $time = null)

This function will return a timestamp corresponding to the next day off after the given time for the given canton., (*11)

If no time is given, current time will be used., (*12)

getNextDaysOff($time = null)

This function will return an associative array which will contain canton two letters code / time of its next day off after the given time., (*13)

If no time is given, current time will be used., (*14)

SwissOff

SwissOff object consists of a list of isSpecificDayOff and getSpecificDayOff function that will check if given time is, for example, Easter / Christmas / Palm Sunday / ... and get the day off., (*15)

For example getChristmas($time = null) will return the timestamp of the Christmas date of the year of the given time., (*16)

isChristmas($time = null) will check if the given time corresponds to a Christmas day, (*17)

Functions name are constructed using is + day off machine name (case sensitive) which are listed below: - Easter - Christmas - NewYear - Berchtold - Epiphany - RepublicDay - Joseph - Nafelser - Palm - GoodFriday - EasterMonday - LaborDay - Ascension - Pentecost - WhitMonday - CorpusChristi - Independance - PeterPaul - National - Assumption - JeuneGenevois - Thanksgiving - Jeune - NicolasFlue - AllSaint - Immaculate - Stephen - Restoration - NewEve, (*18)

The Versions

21/06 2017

dev-master

9999999-dev

PHP Library used to know if a day is off in a given Swiss Canton

  Sources   Download

Apache-2.0

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

by Dominique Vienne

php

21/06 2017

v1.2-stable

1.2.0.0

PHP Library used to know if a day is off in a given Swiss Canton

  Sources   Download

Apache-2.0

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

by Dominique Vienne

php

20/06 2017

v1.0

1.0.0.0

PHP Library used to know if a day is off in a given Swiss Canton

  Sources   Download

Apache-2.0

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

by Dominique Vienne

php

20/06 2017

v1.1-stable

1.1.0.0

PHP Library used to know if a day is off in a given Swiss Canton

  Sources   Download

Apache-2.0

The Requires

  • php ^5.3.3 || ^7.0

 

The Development Requires

by Dominique Vienne

php