Discordian Date Perl File

Newsgroups: alt.discordia
From: puckett @ brtph898 . bnr . ca (S. B. Puckett)
Subject: ddate.perl
Organization: Screaming Lizard Propulsion Systems
Date: Wed, 8 Dec 1993 13:44:07 GMT




For your geeky pleasure, the following is a perl program which gives today's date in the traditional Discordian format. It also notifies you of holy days and other such nonsense. There are no bugs in it, so don't report any to me. It works just fine the way it is.

To run it, store it in a file named something creative like "ddate.perl" and then enter the command "perl ddate.perl". Happy dating.

All hail Discordia,
-Rev. D. U. Puckett, Durham Discordian Glee Club
Prince of the Southern Provinces



############################################################################## # # # ddate - Discordian date # Version FIVE # # This program takes no arguments. It doesn't take shit from _anyone_. # # It returns today's date in the Discordian calendar format. It also # tells you if today is a Holyday. # # This program is written in perl to maximize the amount of chaos in # the implementation. Kallisti (K) 1993, Screaming Lizard Propulsion # Systems. All rights reversed. Mess with this program. Call it your # own. Hail Eris. -><- # # Hugs and Kisses, # Reverend I. C. Puckett, Durham Discordian Glee Club # Prince of the Southern Provinces # # ############################################################################## # Set the century. If you don't know what the current century is, # ask your system administrator. $century = 2000; # Say, how 'bout them month things? @days_in_the_months = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); # Use the groovy perl time interface. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime; # Fix the screwed up results from the groovy perl time interface. $mon++; $year += $century; # And convert to Discordian calendar. @greyface_date = ($mday, $mon, $year); @discordian_date = do convert_date(@greyface_date); # Print the result. do print_discordian_date(@discordian_date); # To run a self-test of all the days in the year, set this bad boy # true. if (4==5) { print "\nTesting...\n"; for ($month = 1; $month <= 12; $month++) { for ($day = 1; $day <= @days_in_the_months[$month-1]; $day++) { do print_discordian_date(do convert_date(($day,$month,1992))); # Test St. Tib's day if (($day == 28) && ($month == 2)) { do print_discordian_date(do convert_date((29,2,1992))); } } } } sub convert_date { local($gday, $gmon, $gyear) = @_; local($dweekday, $dday, $dseason, $dyear) = (-5, -5, -5, -5); local($fnord); # Figure out the correct year. Easy peasy. $dyear = $gyear + 1166; # Now what day of the year is this? local($day_of_year) = $gday; for (1 .. ($gmon - 1)) { $day_of_year += @days_in_the_months[$_ - 1]; } ###### print "Day of year: $day_of_year\n"; # What season is it? Seasons are seventy-three days long. There # are _five_ seasons in a year. Seven minus three is four, which is # two squared. Take one of those twos, and add it to the three: # you get _five_. Take the other two, subtract it from the seven: # you get _five_. $dseason = int(($day_of_year-1) / 73) + 1; if (($gmon == 2) && ($gday == 29)) { # Happy St. Tib's day! Time for Jello (tm). $dweekday = 0; $dday = 0; } else { # St. Tib will have to wait. $dweekday = (($day_of_year - 1) % 5) + 1; $dday = (($day_of_year - 1) % 73) + 1; } return ($dweekday, $dday, $dseason, $dyear); } sub print_discordian_date { local ($dweekday, $dday, $dseason, $dyear); $dweekday = ( "Saint Tib's Day", "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange", )[@_[0]]; if (@_[1] == 0) { $dday = "between 59 and 60"; } else { $dday = @_[1]; } $dseason = ( "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath", )[@_[2] - 1]; $dyear = @_[3]; print "Today is $dweekday, day $dday in the season of $dseason, $dyear.\n"; ###### print "\t@_[0]\t@_[1]\t@_[2]\t@_[3]\n"; # Handle the Apostle Holydays. Rejoice rejoice. Whee. if ($dday == 5) # is today a holy day? huh? { local($aholyday)=( "Mungday", "Mojoday", "Syaday", "Zaraday", "Maladay", )[@_[2] - 1]; print "It is the sacred Apostle Holyday of $aholyday.\n"; } # Handle the Season Holydays. The crowd goes wild. Who celebrates # these things anyway? if ($dday == 50) # is today a holy day? huh? { local($sholyday)=( "Chaoflux", "Discoflux", "Confuflux", "Bureflux", "Afflux", )[@_[2] - 1]; print "It is the sacred Season Holyday of $sholyday.\n"; } } ############################################################################### # YOU MAY NOW SAFELY DESTROY YOUR COMPUTER # ###############################################################################