-
-
Save iamtchelo/7341141 to your computer and use it in GitHub Desktop.
This file contains 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 | |
class Eclesiasticos | |
{ | |
private $ano; | |
private $pascoa; | |
public function __construct($ano) | |
{ | |
$this->ano = (int) $ano; | |
} | |
private function dmY($gd) | |
{ | |
$mdY = explode('/', jdtogregorian($gd)); | |
return array($mdY[1], $mdY[0], $mdY[2]); | |
} | |
public function carnaval() | |
{ | |
list($d, $m, $y) = $this->pascoa($this->ano); | |
//O Carnaval ocorre 47 dias antes da Páscoa | |
return $this->dmY(gregoriantojd($m, $d, $y)- 47); | |
} | |
public function corpusChristi() | |
{ | |
list($d, $m, $y) = $this->pascoa($this->ano); | |
//Corpus Christi ocorre 60 dias após a Páscoa | |
return $this->dmY(gregoriantojd($m, $d, $y)+ 60); | |
} | |
public function pascoa() | |
{ | |
if ($this->pascoa !== null) { | |
return $this->pascoa; | |
} | |
//A = o resto de (Ano ÷ 19) | |
$a = $this->ano % 19; | |
//B = o inteiro de (Ano ÷ 100) | |
$b = (int) ($this->ano / 100); | |
//C = o resto de (Ano ÷ 100) | |
$c = $this->ano % 100; | |
//D = o inteiro de (B ÷ 4) | |
$d = (int) ($b / 4); | |
//E = o resto de (B ÷ 4) | |
$e = $b % 4; | |
//F = o inteiro de [(B + 8) ÷ 25] | |
$f = (int) (($b + 8) / 25); | |
//G = o inteiro de [(B - F + 1) ÷ 3] | |
$g = (int) (($b - $f + 1) / 3); | |
//H = o resto de [(19xA + B - D - G + 15) ÷ 30] | |
$h = (19 * $a + $b - $d - $g + 15) % 30; | |
//I = o inteiro de (C ÷ 4) | |
$i = (int) ($c / 4); | |
//K = o resto de (C ÷ 4) | |
$k = $c % 4; | |
//L = o resto de [(32 + 2xE + 2xI - H - K) ÷ 7] | |
$l = (32 + 2 * $e + 2 * $i - $h - $k) % 7; | |
//M = o inteiro de [(A + 11xH + 22xL) ÷ 451] | |
$m = (int) (($a + 11 * $h + 22 * $l) / 451); | |
//P = o inteiro de [(H + L - 7xM + 114) ÷ 31] | |
$p = (int) (($h + $l - 7 * $m + 114) / 31); | |
//Q = o resto de [(H + L - 7xM + 114) ÷ 31] | |
$q = ($h + $l - 7 * $m + 114) % 31; | |
//A Páscoa será no dia Q+1 do mês P. | |
return $this->pascoa = array($q + 1, $p, $this->ano); | |
} | |
} |
This file contains 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
O carnaval ocorre(u) em 12/02 de 2013 | |
A pascoa ocorre(u) em 31/03 de 2013 | |
Corpus Christi ocorre(u) em 30/05 de 2013 |
This file contains 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 | |
$e = new Eclesiasticos(2013); | |
vprintf("O carnaval ocorre(u) em %02d/%02d de %04d\n", $e->carnaval()); | |
vprintf("A pascoa ocorre(u) em %02d/%02d de %04d\n", $e->pascoa()); | |
vprintf("Corpus Christi ocorre(u) em %02d/%02d de %04d\n", $e->corpusChristi()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment