Created
May 11, 2018 15:27
-
-
Save lenivene/135ab159281475ac01597f1c74cc13fd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function dias_feriados( $year = null ){ | |
if( $year === null ){ | |
$year = intval( date( 'Y' ) ); | |
} | |
/** | |
* easter_date() will generate a warning | |
* if the year is outside of the range | |
* for Unix timestamps (i.e. before 1970 or after 2037). | |
*/ | |
$easter = easter_date( $year ); | |
$easter_day = date( 'j', $easter ); | |
$easter_month = date( 'n', $easter ); | |
$easter_year = date( 'Y', $easter ); | |
$feriados = array( | |
mktime( 0, 0, 0, 1, 1, $year ), // Confraternização Universal | |
mktime( 0, 0, 0, 4, 21, $year ), // Tiradentes | |
mktime( 0, 0, 0, 5, 1, $year ), // Dia do Trabalhador | |
mktime( 0, 0, 0, 6, 12, $year ), // Dia dos Namorados | |
mktime( 0, 0, 0, 6, 24, $year ), // Dia de São João | |
mktime( 0, 0, 0, 9, 7, $year ), // Dia da Independência | |
mktime( 0, 0, 0, 10, 12, $year ), // N. S. Aparecida | |
mktime( 0, 0, 0, 11, 2, $year ), // Todos os santos | |
mktime( 0, 0, 0, 11, 15, $year ), // Proclamação da republica | |
mktime( 0, 0, 0, 12, 25, $year ), // Natal | |
// These days have a date depending on easter | |
mktime( 0, 0, 0, $easter_month, $easter_day - 48, $easter_year ), //2ºferia Carnaval | |
mktime( 0, 0, 0, $easter_month, $easter_day - 47, $easter_year ), //3ºferia Carnaval | |
mktime( 0, 0, 0, $easter_month, $easter_day - 2 , $easter_year ), //6ºfeira Santa | |
mktime( 0, 0, 0, $easter_month, $easter_day , $easter_year ), //Pascoa | |
mktime( 0, 0, 0, $easter_month, $easter_day + 60, $easter_year ), //Corpus Cirist | |
); | |
sort( $feriados ); | |
return $feriados; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment