Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Skrypt przypominający o świętach.
Lejto
post
Post #1





Grupa: Zarejestrowani
Postów: 1 385
Pomógł: 48
Dołączył: 23.05.2007

Ostrzeżenie: (0%)
-----


Tak jak w temacie.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
vokiel
post
Post #2





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Taka prosta klasa, którą trudno nazwać klasą (IMG:style_emoticons/default/biggrin.gif) . Użycia nie trudno się domyśleć...
  1. <?php
  2. /**
  3.  * Klasa do obsługi dni świątecznych (wolnych od pracy)
  4.  * @author Vokiel | <a href="http://vokiel.com" target="_blank">http://vokiel.com</a>
  5.  */
  6. class christmassDays{
  7. private $christmassDays = array();
  8.  
  9. /**
  10. * Tworzenie listy świąt w danym roku
  11. *
  12. * @param int $year
  13. */
  14. public function __construct($year){
  15. $easter = easter_date(intval($year));
  16. $this->christmassDays = array(
  17. $year.'-01-01', // nowy rok
  18. date('Y-m-d', $easter), // pierwszy dzien wielkiej nocy
  19. date('Y-m-d', strtotime('+ 1 day', $easter)), // drugi dzien wielkiej nocy
  20. $year.'-05-01', // 1 maja
  21. $year.'-05-03', // 3 maja
  22. date('Y-m-d', strtotime('+ 49 days', $easter)), // zielone swiatki
  23. date('Y-m-d', strtotime('+ 60 days', $easter)), // boze cialo
  24. $year.'-08-15', // 15 sierpnia
  25. $year.'-11-01', // 1 listopada
  26. $year.'-11-11', // 11 listopada
  27. $year.'-12-25', // 25 grudnia
  28. $year.'-12-26' // 26 grudnia
  29. );
  30. }// end of __construct
  31. /**
  32. * Sprawdzenie czy dana data to święto
  33. *
  34. * @param string $data
  35. * @return bool
  36. */
  37. public function checkChristmassDay($data){
  38. if (in_array($data,$this->christmassDays)){
  39. return true;
  40. } else if (date('w',strtotime($data))==0){
  41. return true;
  42. }
  43. return false;
  44. } // end of checkChristmassDay
  45. }// edn of christmassDays class
  46. ?>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 11.10.2025 - 07:17