Dumaguete Info Search


How to Calendar Math - A Lesson in Logic

Discussion in 'Science and Technology' started by Rye83, Apr 17, 2015.

  1. Rye83

    Rye83 with pastrami Admin Secured Account Highly Rated Poster SC Connoisseur Veteran Army

    Messages:
    13,106
    Trophy Points:
    451
    Occupation:
    FIRE
    Location:
    Valencia
    Ratings:
    +16,069 / 3,795
    Blood Type:
    O+
    So I'm trying to add the Philippines holidays to the forum Calendar but I'm having some problems figuring out the code. Fixed holidays are no problem, I can do this no problem. The movable holidays though......I'm not seeing the pattern/logic in the code.

    Fixed holidays look like this:
    PHP:
    if ($m == && $d == 1)    // jan 1
        
    return "New Year's Day";

    if (
    $m == && $d == 14// feb 14
        
    return "Valentine's Day";

    if (
    $m == && $d == 17// mar 17
        
    return "St. Patrick's Day";
    This is pretty easy for someone who doesn't understand a bit of php.

    Movable holidays look like this:
    PHP:
    if ($m == && match_day($y$m$d13))    // 3rd mon in jan
        
    return "Martin Luther King Day";

    if (
    $m == && match_day($y$m$d13)) // 3rd mon in feb
        
    return "President's Day";

    if (
    $m == && match_day($y$m$d02)) // 2nd sun in may
        
    return "Mother's Day";

    if (
    $m == 11 && match_day($y$m$d54)) // 4th fri in nov
        
    return "Black Friday";
    To start off with, I'm absolutely horrible with anything involving a calendar. I have no idea what months have how many days and if months are written in numeric form I have to say them in my head to figure out the ones in the middle.....so, this crap is just not making any d*mn sense to me.

    I am getting lost on the last set of digits in these strings of code. After the $d you have two numbers the first one I am assuming is the day, with 0=Sunday, 1=Monday and so on. The second number is maybe how many of the days it is into the month? Ah....ok. Worked it out. Painfully obvious now. I will probably forget this so I will just go ahead and post it for future reference. :banghead:
     
  2. Dave & Imp

    Dave & Imp DI Forum Patron Highly Rated Poster Showcase Reviewer

    Messages:
    1,887
    Trophy Points:
    306
    Ratings:
    +1,703 / 884
    So are you saying you do can not calculate which days of the month are going to be hell with you GF? I used to try then I realized.... almost everyday was hell... got a new GF. :wink:
     
  3. OP
    OP
    Rye83

    Rye83 with pastrami Admin Secured Account Highly Rated Poster SC Connoisseur Veteran Army

    Messages:
    13,106
    Trophy Points:
    451
    Occupation:
    FIRE
    Location:
    Valencia
    Ratings:
    +16,069 / 3,795
    Blood Type:
    O+
    • Like Like x 1
  4. OP
    OP
    Rye83

    Rye83 with pastrami Admin Secured Account Highly Rated Poster SC Connoisseur Veteran Army

    Messages:
    13,106
    Trophy Points:
    451
    Occupation:
    FIRE
    Location:
    Valencia
    Ratings:
    +16,069 / 3,795
    Blood Type:
    O+
    I have added most of the national holidays in the Philippines. I have excluded several religious holidays because of the complexity of the days they fall on (it's nothing against Easter or Ramadan, I just have no earthly clue how to make it show for holidays that revolve around a equinox/lunar cycle....nor am I motivated enough to learn how to). So far I have added the "regular holidays" from this wikipedia page. If anyone knows of additional holidays/non-working days please share the date (or day of the month) and I will get it added to the calendar.

    Note that US holidays are on the calendar because they were already there. I have added a "U.S." to these holiday's names so people will know that it is not a Philippine holiday. I have also added the Tagalog translation to the Philippine holidays to further differentiate.

    If I can get a list of local holidays and Fiestas I will add them as well.
     
    • Like Like x 1
Loading...