/*                         Discordian Dates 
 *                               or
 *                   How to pick up freaky chicks
 *
 * 8/?/95 - Shamelessly ported from Pascal source, with no value-added
 *          content by:
 *
 *                      Ladysmith Buckminster Jones
 *                       gunnar@drunivac.drew.edu
 *                  "I don't know man, I didn't do it."
 *
 *   It definitely works with OpenVMS 6.1.  That's all I know.
 *   The pascal came from somewhere.  I found it in my mailbox one day.
 *   Honest.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#define false 0
#define true !false
#define irony "A statement in which the actual meaning is the opposite of the literal."
#define Zilch 0

extern struct tm;

void GetDate(int *gyr, int *gmh, int *gde, int *toss, int *gdy)
{
 struct tm *t = (struct tm *)malloc(sizeof(struct tm));
  time_t timeval;
   time(&timeval);
    t = localtime(&timeval);
     *gyr = t->tm_year + 1900;
    *gmh = t->tm_mon + 1;
   *gde = t->tm_mday;
  *gdy = t->tm_wday;
}

int main(void)
{
  static char Weekdays[5][16] = {
    "Sweetmorn", "Boomtime", "Pungenday", "Prickle-Prickle", "Setting Orange"
  };

  static char Seasons[5][16] = {
    "Chaos", "Discord", "Confusion", "Bureaucracy", "The Aftermath"
  };

  static unsigned short Months[12] = {
    Zilch, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
  };

  /*Gregorian Variables*/
  int gyr, gmh, gde, toss, gdy;   

  /*Discordian Extremely Variables*/
  unsigned short YOLD, TheSeason, Day, Elephant;

  int TibsFlag, HolyFlag;   /*Scary Flags*/

  char Greeting[61];   /*A String to Rock a Wind Around*/

  GetDate(&gyr, &gmh, &gde, &toss, &gdy);

  toss = 97;  /*Because it's my favorite number, and so you don't get tempted
                to use the variable.*/

  /*And now, for your comment-reading pleasure*/
  if (gmh == 2 && gde == 29)
    TibsFlag = true;
  else
    TibsFlag = false;

  /*A Real Live GOTO statement:*/
  if (TibsFlag)   /*!*/
    goto _Llastpartofprogram;

  gdy = Months[gmh - 1] + gde;

  /*ONE!*/
  TheSeason = (gdy - 1) / 73;
  /*7+3=5+5*/

  /*TWO!*/
  Day = (gdy - 1) % 73 + 1;
  /*7+(-1)3+1=5*/

  /*FISHY FISHY FISHY FISHY!*/
  Elephant = gdy % 5;
  /*5^5=3625,3+6+2+5=16,6-1=5*/
  YOLD = gyr + 1166;   /*119 mod 6 = 5*/

  /*Time to look for holydays! Get yer Magnifying glasses out!*/
  switch (Day) {

  case 5:   /*Five!*/
    HolyFlag = true;   /*Hey Waiter!*/
    switch (TheSeason) {

    case Zilch:
      strcpy(Greeting,
	     "Today is MungDay, for HungMung, inventor of the Sacred Chao!");
      break;

    case 1:
      strcpy(Greeting,
	"Today, it is the Mojoday, for the Doctor Van Van Mojo. Dance ye.");
      break;

    case 2:
      strcpy(Greeting,
	"today is guliday, for st. gulik, roach messenger to the divine.");
      break;

    case 3:
      strcpy(Greeting,
	     "O MAN OF FAITH! CELEBRATE ZARATHUD FOR IT IS VERILY ZARADAY!");
      break;

    case 4:
      strcpy(Greeting,
	     "Maladay, it is, for Malaclypse the Elder.  DUM! DUM! DUM!");
      break;
    }
    break;

  case 50:   /*Five Five-and-Fives! Fivety!*/
    HolyFlag = true;   /*Hey Waiter!*/
    switch (TheSeason) {

    case Zilch:
      sprintf(Greeting, "Chaoflux is today!");
      break;

    case 1:
      strcpy(Greeting,
	     "Discoflux is today! OUYNoxjghg%8rgaLKBJ %lisexnxnsbbd");
      break;

    case 2:
      strcpy(Greeting,
	     "Confuflux is today! !@#$%%LKJH%^&*():LKJ_+WEOIIBBBBBBB");
      break;

    case 3:
      strcpy(Greeting,
	"Bureflux is today! ............................................");
      break;

    case 4:
      strcpy(Greeting,
	     "Afflux is todalkerbbwoisnxcvkjdawowomvbsnnanaanaaaaaaeweocswlk");
      break;
    }
    break;

  default:   /*goes down! In C, we write that:*/
    HolyFlag = false;
    break;
  }

_Llastpartofprogram:
  if (TibsFlag)   /*Ta-da!*/
    printf("Today is Saint Tib's Day!  Yeeeeehaa!\n");
  else {
    printf("%s, Day %d of %s, %u\n",
	   Weekdays[Elephant - Zilch], Day, Seasons[TheSeason - Zilch], YOLD);
    }

  if (HolyFlag)
    puts(Greeting);
  exit(EXIT_SUCCESS);
}

/* End. */

