September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,62 +1,82 @@
|
|||
<?php
|
||||
// Discordian dating machine. Accepts date from PHP function date() or from the URL.
|
||||
// The Discordian calendar has 5 days in a week, 73 days in a month and 5 months in a year.
|
||||
// Ex. ddate.php will generate todays date according to your computer
|
||||
// Ex. ddate.php?y=2012&m=2&y=29 will generate the date for Feb. 29, 2012
|
||||
$Anerisia = array(31,28,31,30,31,30,31,31,30,31,30,31);
|
||||
$MONTHS = array("Choas","Discord","Confusion","Bureacracy","The Aftermath");
|
||||
$DAYS = array("Setting Orange","Sweetmorn","BoomTime","Pungenday","Prickle-Prickle");
|
||||
$Dsuff = array('th','st','nd','rd','th','th','th','th','th','th');
|
||||
$Holy5 = array("Mungday","MojoDay","Syaday","Zaraday","Maladay");
|
||||
$Holy50 = array("Chaoflux","Discoflux","Confuflux","Bureflux","Afflux");
|
||||
|
||||
$DAYS = array("Sweetmorn","Boomtime","Pungenday","Prickle-Prickle","Setting Orange");
|
||||
$MONTHS = array("Chaos","Discord","Confusion","Bureaucracy","The Aftermath");
|
||||
|
||||
// If user passed year, month and day variables in URL
|
||||
if(isset($_GET['y']) && isset($_GET['m']) && isset($_GET['d'])) {
|
||||
// Get year, month and day from URL
|
||||
$usery = $_GET['y']; $userm = $_GET['m']; $userd = $_GET['d'];
|
||||
// Use unix time to calculate day of year starting at zero
|
||||
$userdate = mktime(0,0,0,$userm,$userd,$usery);
|
||||
$ddays = ($userdate - mktime(0,0,0,1,1,$usery)) / 86400;
|
||||
// Calculates the Discordian year, month and day
|
||||
$dyear = ($usery) + 1166; $dmonth = $MONTHS[$dday/73]; $dday = $ddays%73 + 1;
|
||||
}
|
||||
// If user didn't pass year, get date from PHP function
|
||||
else {
|
||||
// Create array containing current Gregorian year, month, day,
|
||||
// days of year starting at zero and whether or not year is a leap
|
||||
$date = explode(" ",date('Y n j z L'));
|
||||
// Calculates the Discordian year, month and day
|
||||
$dyear = $date[0]+1166; $dmonth = $MONTHS[$date[3]/73]; $dday = $date[3]%73 +1;
|
||||
}
|
||||
// Determine the name of the day
|
||||
if ($ddays === NULL) { $ddayname= $DAYS[$date[3]%5]; }
|
||||
else { $ddayname= $DAYS[$ddays%5]; }
|
||||
|
||||
// Leap year exception for date from PHP
|
||||
if ($ddays === NULL) {
|
||||
if ($date[4]) {
|
||||
if ($date[1] == 2 && $date[2] == 29) { echo "Today is St. Tib's Day, YOLD " . $dyear; }
|
||||
if ($date[3] >= 60) { //offset day by one if leap year
|
||||
$dday -= 1;
|
||||
if($dday % 5 == 0) $ddayname = $DAYS[4];
|
||||
else $ddayname = $DAYS[($dday%5)];
|
||||
}
|
||||
}
|
||||
// Display Discordian date
|
||||
echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear;
|
||||
}
|
||||
else { // Leap year exception for date from URL
|
||||
if ($usery % 100 == 0) { // leap year exception for years that are divisible by one hundred
|
||||
if ($usery % 400 == 0 && $userm == 2 && $userd == 29) { echo "Today is St. Tib's Day, YOLD " . $dyear; }
|
||||
}
|
||||
else if ($usery % 4 == 0) { // if the year is a leap year
|
||||
if ($userm == 2 && $userd == 29) { echo "Today is St. Tib's Day, YOLD " . $dyear; }
|
||||
elseif ($ddays >= 60) { // offset day by one if leap year
|
||||
$dday -=1;
|
||||
if($dday % 5 == 0) $ddayname = $DAYS[4];
|
||||
else $ddayname=$DAYS[($dday%5-1)];
|
||||
echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear;
|
||||
}
|
||||
else { echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; }
|
||||
}
|
||||
// Display Discordian date
|
||||
else { echo "Today is " . $ddayname . ", " . $dmonth . " " . $dday . ", YOLD " . $dyear; }
|
||||
}
|
||||
?>
|
||||
|
||||
// Get the current system date and assign to some variables
|
||||
$edate = explode(" ",date('Y m j L'));
|
||||
$usery = $edate[0];
|
||||
$userm = $edate[1];
|
||||
$userd = $edate[2];
|
||||
$IsLeap = $edate[3];
|
||||
|
||||
// If the user supplied us with a date overide the one we got from the system.
|
||||
// If you could get the date from users browser via javascript and then call
|
||||
// this script with the users date. ddate.php?y=year&m=month&d=day mostly it
|
||||
// won't matter but if the server is in a different time zone to the user
|
||||
// There will be occasional incorrect results from the users POV.
|
||||
|
||||
if (isset($_GET['y']) && isset($_GET['m']) && isset($_GET['d'])) {
|
||||
$usery = $_GET['y'];
|
||||
$userm = $_GET['m'];
|
||||
$userd = $_GET['d'];
|
||||
$IsLeap = 0;
|
||||
if (($usery%4 == 0) && ($usery%100 >0)) $IsLeap =1;
|
||||
if ($usery%400 == 0) $IsLeap = 1;
|
||||
}
|
||||
|
||||
// We need to know the total number of days in the year so far
|
||||
|
||||
$userdays = 0;
|
||||
$i = 0;
|
||||
while ($i < ($userm-1)) {
|
||||
|
||||
$userdays = $userdays + $Anerisia[$i];
|
||||
$i = $i +1;
|
||||
}
|
||||
$userdays = $userdays + $userd;
|
||||
|
||||
// We can now work out the full discordian date for most dates
|
||||
// PHP does not do integer division, so we use 73.2 as a divisor
|
||||
// the value 73.2 works, larger values cause an off-by-one on season
|
||||
// changes for the later seasons .
|
||||
// This is not needed with the mod operator.
|
||||
|
||||
$IsHolyday = 0;
|
||||
$dyear = $usery + 1166;
|
||||
$dmonth = $MONTHS[$userdays/73.2];
|
||||
$dday = $userdays%73;
|
||||
if (0 == $dday) $dday = 73;
|
||||
$Dname = $DAYS[$userdays%5];
|
||||
$Holyday = "St. Tibs Day";
|
||||
if ($dday == 5) {
|
||||
$Holyday = $Holy5[$userdays/73.2];
|
||||
$IsHolyday =1;
|
||||
}
|
||||
if ($dday == 50) {
|
||||
$Holyday = $Holy50[$userdays/73.2];
|
||||
$IsHolyday =1;
|
||||
}
|
||||
|
||||
if (($IsLeap ==1) && ($userd ==29) and ($userm ==2)) $IsHolyday = 2;
|
||||
|
||||
// work out the suffix to the day number
|
||||
$suff = $Dsuff[$dday%10] ;
|
||||
if ((11 <= $dday) && (19 >= $dday)) $suff='th';
|
||||
|
||||
// code to display the date ...
|
||||
|
||||
if ($IsHolyday ==2)
|
||||
echo "</br>Celeberate ",$Holyday," ",$dmonth," YOLD ",$dyear;
|
||||
if ($IsHolyday ==1)
|
||||
echo "</br>Celeberate for today ", $Dname , " The ", $dday,"<sup>",$suff,"</sup>", " day of ", $dmonth , " YOLD " , $dyear , " is the holy day of " , $Holyday;
|
||||
if ($IsHolyday == 0)
|
||||
echo "</br>Today is " , $Dname , " the " , $dday ,"<sup>",$suff, "</sup> day of " , $dmonth , " YOLD " , $dyear;
|
||||
|
||||
?>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue