PHP Classes

PHP Swiss Day Off: Check if a given day is off in Switzerland

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 29 All time: 11,144 This week: 660Up
Version License PHP version Categories
swiss-off 1.0Free for non-comm...5Localization, PHP 5, Time and Date
Description 

Author

This package is specific mainly for applications used in Switzerland Switzerland .

This package can be used to check if a given day is off in Switzerland.

It can take as parameter the date of a given day and checks it is an holiday or a day on which regular Swiss Canton employees do not have to work.

The package can also perform other checks related with off days like get the date of the next day off or get the holiday name of a certain day off.

Picture of Dominique Vienne
Name: Dominique Vienne <contact>
Classes: 3 packages by
Country: Switzerland Switzerland
Age: ???
All time rank: 393132 in Switzerland Switzerland
Week rank: 192 Up4 in Switzerland Switzerland Up
Innovation award
Innovation award
Nominee: 1x

Documentation

swissOff

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

Installation

Recommended

Go to you project root directory and use composer using this command

composer require dominiquevienne/swiss-off

Then create your application bootstrap using this kind of code

<?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

composer require dominiquevienne/swiss-off

and add the following lines in your class

<?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. 
### 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). 

If no time is given, current time will be used. 
#### getDaysOffNames()
This function will return an array containing all days off machine name (eg. Christmas, Berchtold, ...)
#### getCantonsByDayOffName($dayOffName)
This function will return an array containing all cantons that are off for this day off. 
#### getNextDayOffByCanton($canton, $time = null)
This function will return a timestamp corresponding to the next day off after the given time for the given canton. 

If no time is given, current time will be used. 
#### 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. 

If no time is given, current time will be used. 
### 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.

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

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

 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

  Files folder image Files (9)  
File Role Description
Files folder imagesrc (1 directory)
Files folder imagetests (2 files)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file README.md Doc. Read me

  Files folder image Files (9)  /  src  
File Role Description
Files folder imageDominiquevienne (1 directory)

  Files folder image Files (9)  /  src  /  Dominiquevienne  
File Role Description
Files folder imageSwissOff (2 files)

  Files folder image Files (9)  /  src  /  Dominiquevienne  /  SwissOff  
File Role Description
  Plain text file Canton.php Class Class source
  Plain text file SwissOff.php Class Class source

  Files folder image Files (9)  /  tests  
File Role Description
  Plain text file CantonTest.php Class Class source
  Plain text file SwissOffTest.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:29
This week:0
All time:11,144
This week:660Up