#!/usr/bin/perl use Time::Local; $CLCSecondsOffset = 24003196; $CLCYearOffset = 411; $CLCDaysInMonth = 90; $CLCSecondsInYear = 31104000; $CLCSecondsInDay = 86400; $CLCHalfSecondsInDay = 43200; $CLCSecondsInHour = 3600; $CLCSecondsInMinute = 60; $daylightSavings = 3600; @WEEKDAYS = ("Lundi","Gradi","Terrdi","Merdi","Fordi","Sombdi","Soldi"); @SEASONS = ("Winter","Spring","Summer","Autumn"); @ZODIACNAMED = ("0fake","Oobiscus the Foxweir","Eghorus the Rooster","Ina D' Xus the Warrior","Orcipus the Pig","Falinea the Centaur","Ma'Taline the Mystic","Detros the Ruknee","Awjus and Hamusa the Shredders","Josephus the Ancient","Enba the Rat","Elixus The Cat","Shaer the Healer"); if($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $form{$name} = $value; } $wasGivenDate = 1; } else { $timeGiven = time; $wasGivenDate = 0; } if($wasGivenDate) { if($form{'type'} eq 'ooc') { @timeDateSplit = split(/ /, $form{'timeDateString'}); @timeSplit = split(/:/, $timeDateSplit[0]); @dateSplit = split(/-/, $timeDateSplit[1]); $timeGiven = timelocal(0,$timeSplit[1],($timeSplit[0] - 1),$dateSplit[1],($dateSplit[0] - 1),$dateSplit[2]) + 3600; } elsif($form{'type'} eq 'ic') { @timeDateSplit = split(/ /, $form{'timeDateString'}); @timeSplit = split(/:/, $timeDateSplit[0]); @dateSplit = split(/-/, $timeDateSplit[1]); $firstTwo = substr($dateSplit[0],0,2); if(($firstTwo eq "Wi") || ($firstTwo eq "wi")) { $dateMonth = 0; } elsif(($firstTwo eq "Sp") || ($firstTwo eq "sp")) { $dateMonth = 1; } elsif(($firstTwo eq "Su") || ($firstTwo eq "su")) { $dateMonth = 2; } elsif(($firstTwo eq "Au") || ($firstTwo eq "au")) { $dateMonth = 3; } $timeGiven = ((((($dateSplit[2] - $CLCYearOffset) * $CLCSecondsInYear) + (($dateSplit[1] + ($dateMonth * $CLCDaysInMonth)) * $CLCSecondsInDay) + ($timeSplit[0] * $CLCSecondsInHour) + ($timeSplit[1] * $CLCSecondsInMinute) - $CLCSecondsOffset) * 11) / 45) + $daylightSavings; } } @timeDateGiven = localtime($timeGiven); $puddlebyTime = ((($timeGiven - $daylightSavings) * 45) / 11) + $CLCSecondsOffset; $puddlebyTimeLowered = $puddlebyTime; $puddlebyYear = int(($puddlebyTimeLowered / $CLCSecondsInYear) + $CLCYearOffset); $puddlebyTimeLowered -= ($puddlebyYear - $CLCYearOffset) * $CLCSecondsInYear; $puddlebyYearDay = int($puddlebyTimeLowered / $CLCSecondsInDay); $puddlebyTimeLowered -= $puddlebyYearDay * $CLCSecondsInDay; $puddlebyHour = int($puddlebyTimeLowered / $CLCSecondsInHour); $puddlebyTimeLowered -= $puddlebyHour * $CLCSecondsInHour; $puddlebyMinute = int($puddlebyTimeLowered / $CLCSecondsInMinute); $puddlebyTimeLowered -= $puddlebyMinute * $CLCSecondsInMinute; $puddlebySecond = int($puddlebyTimeLowered); $puddlebyMonthDay = int((($puddlebyYearDay - 1) % 90) + 1); $puddlebyWeekdayInt = int($puddlebyTime / $CLCSecondsInDay); $puddlebyWeekdayInt %= 7; $puddlebySeasonInt = int(($puddlebyYearDay - 1) / 90); if($puddlebyYearDay == 0) { $puddlebyYearDay = 360; $puddlebyMonthDay = 90; $puddlebyYear -= 1; $puddlebySeasonInt = 4; } if($puddlebyHour == 0) { $puddlebyHourDisplay = 12; $AMPM = "AM"; } elsif($puddlebyHour > 12) { $puddlebyHourDisplay = $puddlebyHour - 12; $AMPM = "PM"; } else { $puddlebyHourDisplay = $puddlebyHour; $AMPM = "AM"; } $puddlebyWeekday = $WEEKDAYS[$puddlebyWeekdayInt]; $puddlebySeason = $SEASONS[$puddlebySeasonInt]; # Sunrise if($puddlebyYearDay <= 180) { $sunriseLong = 540 - (2 * $puddlebyYearDay); } else { $sunriseLong = 180 + (2 * ($puddlebyYearDay - 180)); } $sunriseHour = int($sunriseLong / 60); $sunriseMinute = int($sunriseLong - ($sunriseHour * 60)); $sunriseSecond = int($sunriseLong - ($sunriseMinute + ($sunriseHour * 60))); if($puddlebyYearDay <= 180) { $tomorrowSunriseLong = 540 - (2 * ($puddlebyYearDay+1)); } else { $tomorrowSunriseLong = 180 + (2 * (($puddlebyYearDay + 1) - 180)); } $tomorrowSunriseHour = int($tomorrowSunriseLong / 60); $tomorrowSunriseMinute = int($tomorrowSunriseLong - ($tomorrowSunriseHour * 60)); $tomorrowSunriseSecond = int($tomorrowSunriseLong - ($tomorrowSunriseMinute + ($tomorrowSunriseHour * 60))); $secondsToAdd = (($puddlebyHour - $sunriseHour) * $CLCSecondsInHour) + (($puddlebyMinute - $sunriseMinute) * $CLCSecondsInMinute) + ($puddlebySecond - $sunriseSecond); $sunrise = ((($puddlebyTime - $CLCSecondsOffset - $secondsToAdd) * 11) / 45) + $daylightSavings; $tomorrowSecondsToAdd = ((($puddlebyHour - $tomorrowSunriseHour) * $CLCSecondsInHour) + (($puddlebyMinute - $tomorrowSunriseMinute) * $CLCSecondsInMinute) + ($puddlebySecond - $tomorrowSunriseSecond) - $CLCSecondsInDay); $tomorrowSunrise = ((($puddlebyTime - $CLCSecondsOffset - $tomorrowSecondsToAdd) * 11) / 45) + $daylightSavings; # End Sunrise # Sunset if($puddlebyYearDay <= 180) { $sunsetLong = 900 + (2 * $puddlebyYearDay); } else { $sunsetLong = 1260 - (2 * ($puddlebyYearDay - 180)); } $sunsetHour = int($sunsetLong / 60); $sunsetMinute = int($sunsetLong - ($sunsetHour * 60)); $sunsetSecond = int($sunsetLong - ($sunsetMinute + ($sunsetHour * 60))); if($puddlebyYearDay <= 180) { $tomorrowSunsetLong = 900 + (2 * ($puddlebyYearDay+1)); } else { $tomorrowSunsetLong = 1260 - (2 * (($puddlebyYearDay+1) - 180)); } $tomorrowSunsetHour = int($tomorrowSunsetLong / 60); $tomorrowSunsetMinute = int($tomorrowSunsetLong - ($tomorrowSunsetHour * 60)); $tomorrowSunsetSecond = int($tomorrowSunsetLong - ($tomorrowSunsetMinute + ($tomorrowSunsetHour * 60))); $secondsToAdd = (($puddlebyHour - $sunsetHour) * $CLCSecondsInHour) + (($puddlebyMinute - $sunsetMinute) * $CLCSecondsInMinute) + ($puddlebySecond - $sunsetSecond); $sunset = ((($puddlebyTime - $CLCSecondsOffset - $secondsToAdd) * 11) / 45) + $daylightSavings; $tomorrowSecondsToAdd = ((($puddlebyHour - $tomorrowSunsetHour) * $CLCSecondsInHour) + (($puddlebyMinute - $tomorrowSunsetMinute) * $CLCSecondsInMinute) + ($puddlebySecond - $tomorrowSunsetSecond) - $CLCSecondsInDay); $tomorrowSunset = ((($puddlebyTime - $CLCSecondsOffset - $tomorrowSecondsToAdd) * 11) / 45) + $daylightSavings; # End Sunset # Zodiac $zodiacDay = (($puddlebyTime/$CLCSecondsInDay) + 3) % 29; if($zodiacDay == 0) { $zodiacDay = 29; } $zodiacSymbol = ((($puddlebyTime/$CLCSecondsInDay)) / 29) % 12; if($zodiacSymbol == 0) { $zodiacSymbol = 12; } $daysUntilNextZodiac = 29 - $zodiacDay; if(($zodiacSymbol + 1) > 12) { $nextZodiacSymbol = 1; } else { $nextZodiacSymbol = $zodiacSymbol + 1; } $zodiacName = $ZODIACNAMED[$zodiacSymbol]; $nextZodiacName = $ZODIACNAMED[$nextZodiacSymbol]; # End Zodiac # Coliseum if($puddlebyWeekdayInt == 5) { if($puddlebyHour >= 19) { $coliseum = ((($puddlebyTime - $CLCSecondsOffset + (500400 + ($CLCSecondsInDay - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond)))) * 11) / 45) + $daylightSavings; } else { $coliseum = ((($puddlebyTime - $CLCSecondsOffset + (68400 - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond))) * 11) / 45) + $daylightSavings; } } else { if($puddlebyWeekdayInt == 6) { $coliseum = ((($puddlebyTime - $CLCSecondsOffset + ($CLCSecondsInDay - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond)) + ((6 * $CLCSecondsInDay) - 18000)) * 11) / 45) + $daylightSavings; } else { $coliseum = ((($puddlebyTime - $CLCSecondsOffset + ($CLCSecondsInDay - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond)) + (((6 - $puddlebyWeekdayInt) * $CLCSecondsInDay) - 18000)) * 11) / 45) + $daylightSavings; } } # End Coliseum # Lunar $lunarDay = (($puddlebyTime/$CLCSecondsInDay) + 9) % 28; if($lunarDay == 0) { $lunarDay = 28; } if($lunarDay == 1) { $moonDay = "New Moon"; } elsif(($lunarDay > 1) && ($lunarDay < 8)) { $moonDay = "Waning Crescent"; } elsif($lunarDay == 8) { $moonDay = "First Quarter"; } elsif(($lunarDay > 8) && ($lunarDay < 15)) { $moonDay = "Waning Gibbous"; } elsif($lunarDay == 15) { $moonDay = "Full Moon"; } elsif(($lunarDay > 15) && ($lunarDay < 22)) { $moonDay = "Waxing Gibbous"; } elsif($lunarDay == 22) { $moonDay = "Last Quarter"; } else { $moonDay = "Waxing Crescent"; } # End Lunar # Full Moon if($lunarDay == 15) { $fullMoonStart = $puddlebyTime - $CLCSecondsOffset; $fullMoonStart -= (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond); $fullMoonNoon = $fullMoonStart + $CLCHalfSecondsInDay; $fullMoonEnd = $fullMoonStart + $CLCSecondsInDay; $nextFullMoonStart = $fullMoonStart + ($CLCSecondsInDay * 28); $nextFullMoonNoon = $nextFullMoonStart + $CLCHalfSecondsInDay; $nextFullMoonEnd = $fullMoonEnd + ($CLCSecondsInDay * 28); $fullMoonStart = (($fullMoonStart * 11) / 45) + $daylightSavings; $fullMoonNoon = (($fullMoonNoon * 11) / 45) + $daylightSavings; $fullMoonEnd = (($fullMoonEnd * 11) / 45) + $daylightSavings; $nextFullMoonStart = (($nextFullMoonStart * 11) / 45) + $daylightSavings; $nextFullMoonNoon = (($nextFullMoonNoon * 11) / 45) + $daylightSavings; $nextFullMoonEnd = (($nextFullMoonEnd * 11) / 45) + $daylightSavings; } elsif($lunarDay < 15) { $fullMoonStart = $puddlebyTime - $CLCSecondsOffset + ((14 - $lunarDay) * $CLCSecondsInDay); $fullMoonStart += $CLCSecondsInDay - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond); $fullMoonNoon = $fullMoonStart + $CLCHalfSecondsInDay; $fullMoonEnd = $fullMoonStart + $CLCSecondsInDay; $nextFullMoonStart = $fullMoonStart + ($CLCSecondsInDay * 28); $nextFullMoonNoon = $nextFullMoonStart + $CLCHalfSecondsInDay; $nextFullMoonEnd = $fullMoonEnd + ($CLCSecondsInDay * 28); $fullMoonStart = (($fullMoonStart * 11) / 45) + $daylightSavings; $fullMoonNoon = (($fullMoonNoon * 11) / 45) + $daylightSavings; $fullMoonEnd = (($fullMoonEnd * 11) / 45) + $daylightSavings; $nextFullMoonStart = (($nextFullMoonStart * 11) / 45) + $daylightSavings; $nextFullMoonNoon = (($nextFullMoonNoon * 11) / 45) + $daylightSavings; $nextFullMoonEnd = (($nextFullMoonEnd * 11) / 45) + $daylightSavings; } else { $fullMoonStart = $puddlebyTime - $CLCSecondsOffset + ((28 - $lunarDay) * $CLCSecondsInDay) + 1209600; $fullMoonStart += $CLCSecondsInDay - (($puddlebyHour * $CLCSecondsInHour) + ($puddlebyMinute * $CLCSecondsInMinute) + $puddlebySecond); $fullMoonNoon = $fullMoonStart + $CLCHalfSecondsInDay; $fullMoonEnd = $fullMoonStart + $CLCSecondsInDay; $nextFullMoonStart = $fullMoonStart + ($CLCSecondsInDay * 28); $nextFullMoonNoon = $nextFullMoonStart + $CLCHalfSecondsInDay; $nextFullMoonEnd = $fullMoonEnd + ($CLCSecondsInDay * 28); $fullMoonStart = (($fullMoonStart * 11) / 45) + $daylightSavings; $fullMoonNoon = (($fullMoonNoon * 11) / 45) + $daylightSavings; $fullMoonEnd = (($fullMoonEnd * 11) / 45) + $daylightSavings; $nextFullMoonStart = (($nextFullMoonStart * 11) / 45) + $daylightSavings; $nextFullMoonNoon = (($nextFullMoonNoon * 11) / 45) + $daylightSavings; $nextFullMoonEnd = (($nextFullMoonEnd * 11) / 45) + $daylightSavings; } # End Full Moon # plain text #print "$puddlebyWeekday $puddlebyHourDisplay:$puddlebyMinute:$puddlebySecond $AMPM, day $puddlebyMonthDay of $puddlebySeason, day $puddlebyYearDay of the year $puddlebyYear"; #print "\n\nSunrise at: ".localtime($sunrise)."\tSunset at: ".localtime($sunset); #print "\nTomorrow sunrise at: ".localtime($tomorrowSunrise)."\tTomorrow sunset at: ".localtime($tomorrowSunset); #print "\n\nDay ".$zodiacDay." of ".$zodiacName; #print "\n".$nextZodiacName." rises in ".$daysUntilNextZodiac." days"; # #if(($puddlebyWeekdayInt == 5) && ($puddlebyHour >= 19)) { # print "\n\nColiseum is open now! and next on ".localtime($coliseum); #} else { # print "\n\nColiseum opens at ".localtime($coliseum); #} # #print "\n\n".$moonDay." of the Moon, day ".$lunarDay; # #if($lunarDay == 15) { # print "\nToday's Full Moon:"; # # print "\nStarted at: ".localtime($fullMoonStart); # if($puddlebyHour < 12) { # print "\nNoon is at: ".localtime($fullMoonNoon); # } else { # print "\nNoon was at: ".localtime($fullMoonNoon); # } # print "\nWill end at: %@".localtime($fullMoonEnd); # # print "\n\nNext Full Moon:"; # print "\nStarts at: ".localtime($nextFullMoonStart); # print "\nNoon is at: ".localtime($nextFullMoonNoon); # print "\nEnds at: ".localtime($nextFullMoonEnd); #} else { # print "\nNext Full Moon:"; # # print "\nStarts at: ".localtime($fullMoonStart); # print "\nNoon is at: ".localtime($fullMoonNoon); # print "\nEnds at: ".localtime($fullMoonEnd); # # print "\n\nFull Moon After Next:"; # print "\nStarts at: ".localtime($nextFullMoonStart); # print "\nNoon is at: ".localtime($nextFullMoonNoon); # print "\nEnds at: ".localtime($nextFullMoonEnd); #} #print "\n\n\n"; # html version print "Content-type: text/html\n\n"; print '
| ';
print "$puddlebyWeekday ";
printf '%d:%02d:%02d', $puddlebyHourDisplay,$puddlebyMinute,$puddlebySecond;
print " $AMPM, day $puddlebyMonthDay of $puddlebySeason, day $puddlebyYearDay of the year $puddlebyYear "; # Dawn/Dusk print ' | |
Today: Sunrise at: ".localtime($sunrise)." Sunset at: ".localtime($sunset); print " Tomorrow: Next sunrise at: ".localtime($tomorrowSunrise)." Next sunset at: ".localtime($tomorrowSunset); # Lunar print ' | '; print $moonDay." of the Moon, day ".$lunarDay." "; if($lunarDay == 15) { print " Today's Full Moon:"; print " Started at: ".localtime($fullMoonStart); if($puddlebyHour < 12) { print " Noon is at: ".localtime($fullMoonNoon); } else { print " Noon was at: ".localtime($fullMoonNoon); } print " Will end at: %@".localtime($fullMoonEnd); print " Next Full Moon:"; print " Starts at: ".localtime($nextFullMoonStart); print " Noon is at: ".localtime($nextFullMoonNoon); print " Ends at: ".localtime($nextFullMoonEnd); } else { print " Next Full Moon:"; print " Starts at: ".localtime($fullMoonStart); print " Noon is at: ".localtime($fullMoonNoon); print " Ends at: ".localtime($fullMoonEnd); print " Full Moon After Next:"; print " Starts at: ".localtime($nextFullMoonStart); print " Noon is at: ".localtime($nextFullMoonNoon); print " Ends at: ".localtime($nextFullMoonEnd); } # Zodiac print ' |
'; print " Day ".$zodiacDay." of ".$zodiacName; print " ".$nextZodiacName." rises in ".$daysUntilNextZodiac." days"; # Coliseum print ' | '; if(($puddlebyWeekdayInt == 5) && ($puddlebyHour >= 19)) { print " Coliseum is open now! and next on ".localtime($coliseum); } else { print " Coliseum opens at ".localtime($coliseum); } print ' |