2017 © Pedro PelĂĄez
 

library holiday

Know when a holiday occours in Sweden

image

marwelln/holiday

Know when a holiday occours in Sweden

  • Thursday, June 14, 2018
  • by Marwelln
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 11 % Grown

The README.md

Requirements

This class requires PHP 7.1., (*1)

Installation

For PHP 7.1 and later:, (*2)

composer require marwelln/holiday:~2.0

About

This class helps you know when holidays occours in Sweden. You can either get all holidays in an iterable Marwelln\Holiday\Collection or check when a specific holiday occours. All results returns a DateTime object that you can use to format the date the way you want it., (*3)

Usage

// Get all holidays as a `Marwelln\Holiday\Collection`.
$holidays = (new \Marwelln\Holiday)->get($year); // `$year` can be removed if you want to use current year.
$holidays = (new \Marwelln\Holiday)->year($year)->get();

// Check when easter occours.
$easter = (new \Marwelln\Holiday)->when('easter'); // 27 mars, as of 2016 (current year)
$easter = (new \Marwelln\Holiday)->year(2015)->when('easter'); // 5 april

// Get holidays between two dates.
$holidays = (new \Marwelln\Holiday)->between(new \DateTime('2015-01-01'), new \DateTime('2015-03-24')); // Collection of holidays

// Format the collection.
$holidays = (new \Marwelln\Holiday)->get();
$formatted = $holidays->map(function($holiday){
    return [
        'id' => $holiday['id'],
        'date' => $holiday['date']->format('Y-m-d'),
        'name' => trans('holiday.' . $holiday['id']), // Custom function from Laravel
        'onWeekend' => in_array($holiday['date']->format('N'), [6, 7])
    ];
}, $holidays);

Available holidays

  • newyearseve (nyĂ„rsafton)
  • newyearsday (nyĂ„rsdagen)
  • epiphany (trettondedag jul)
  • easter (pĂ„skdagen)
  • goodfriday (lĂ„ngfredagen)
  • eastermonday (annandag pĂ„sk)
  • ascensionday (kristi himmelfĂ€rdsdag)
  • pentecostday (pingstdagen)
  • mayday (första maj)
  • swedishnationalday (svenska nationaldagen)
  • midsummereve (midsommarafton)
  • midsummerday (midsommardagen)
  • allsaintsday (alla helgons dag)
  • christmaseve (julafton)
  • christmasday (juldagen)
  • boxingday (annandag jul)

The Versions

14/06 2018

dev-master

9999999-dev

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Martin MÄrtensson

14/06 2018

v2.3.1

2.3.1.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Martin MÄrtensson

12/05 2017

v2.3

2.3.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.1

 

The Development Requires

by Martin MÄrtensson

06/05 2017

v2.2

2.2.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Martin MÄrtensson

05/05 2017

v2.1

2.1.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Martin MÄrtensson

16/12 2016

v2.0

2.0.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Martin MÄrtensson

27/08 2016

v1.1

1.1.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Martin MÄrtensson

10/07 2016

dev-php5

dev-php5

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

 

by Martin MÄrtensson

10/07 2016

v1.0

1.0.0.0

Know when a holiday occours in Sweden

  Sources   Download

MIT

The Requires

 

by Martin MÄrtensson