Jump to content

An Alternative Calendar System oops need to factor in leap year...


Recommended Posts

I've created  this script (please excuse my total newb technique) to translate the dates from gregorian dates to this alternative calendar system.

What I did was compare the date with 11.11.11 and then count out from that day to determine what day it is and which cycle(month) it is in relation to that.

This bit I wrote works great - BUT I didn't take into consideration the leap year. and so I have to figure out how to now count leap year days as a copy of the day before it, so if day 21 was the day before the leap year, the leap year day would count as the same and display the same info as day 21, then the following day would continue on to day 22, 23 up to 26 and cycle back to 1 etc..

What I'm hoping is that there's an easy way to factor in the leap year into this script:

 

<?php

$elvenportal = mktime(11,11,11,11,11,2011);
$now = mktime(date("H"),date("i"),date("s"),date("n"),date("j"),date("Y"));
$late = date("H");
$theeday = date("d")-1;
if ($late < 7) {$now = mktime(11,11,11,date("n"),$theeday,date("Y"));}; // timezone correction because of weird server
if ($_POST["dayz"] != "" ){
if ($_POST["month"] != "" ){
if ($_POST["year"] != "" ){
$now = mktime(11,11,11,$_POST["month"],$_POST["dayz"],$_POST["year"]);
};};};

$offset = $now - $elvenportal;
$beyondportal = abs($offset/(60*60*24));


$beyondportal = abs($beyondportal+108);
$day = abs($beyondportal % 26 + 1); //26 days in the cycle.  +1 to make it 1-26 rather than 0-25 
$cycle = abs(intval($beyondportal / 26) % 14+1); //26 days in your cycles.  +1 to make it 1-14 rather than 0-13


if ($elvenportal > $now){
if ($day == 6){$day = 4;}
else if ($day == 7){$day = 3;}
else if ($day == {$day = 2;}
else if ($day == 9){$day = 1;}
else if ($day == 10){$day = 26;}
else if ($day == 11){$day = 25;}
else if ($day == 12){$day = 24;}
else if ($day == 13){$day = 23;}
else if ($day == 14){$day = 22;}
else if ($day == 15){$day = 21;}
else if ($day == 16){$day = 20;}
else if ($day == 17){$day = 19;}
else if ($day == 18){$day = 18;}
else if ($day == 19){$day = 17;}
else if ($day == 20){$day = 16;}
else if ($day == 21){$day = 15;}
else if ($day == 22){$day = 14;}
else if ($day == 23){$day = 13;}
else if ($day == 24){$day = 12;}
else if ($day == 25){$day = 11;}
else if ($day == 26){$day = 10;}
else if ($day == 1){$day = 9;}
else if ($day == 2){$day = 8;}
else if ($day == 3){$day = 7;}
else if ($day == 4){$day = 6;}
else if ($day == 5){$day = 5;}
else if ($day == 6){$day = 4;};

if ($beyondportal > 4){
if ($cycle == 1){$cycle = 8;}
else if ($cycle == 2){$cycle = 7;}
else if ($cycle == 3){$cycle = 6;}
else if ($cycle == 4){$cycle = 5;}
else if ($cycle == 5){$cycle = 4;}
else if ($cycle == 6){$cycle = 3;}
else if ($cycle == 7){$cycle = 2;}
else if ($cycle == {$cycle = 1;}
else if ($cycle == 9){$cycle = 14;}
else if ($cycle == 10){$cycle = 13;}
else if ($cycle == 11){$cycle = 12;}
else if ($cycle == 12){$cycle = 11;}
else if ($cycle == 13){$cycle = 10;}
else if ($cycle == 14){$cycle = 9;};
};


};
?>

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.