Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- a switch for aneristic purposes #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions ddate.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ ddate \- convert Gregorian dates to Discordian dates
.B ddate
.RI [ \fB+\fPformat]
.RI [ date ]
.B ddate
.RI \-a
.RI [ date ]
.SH DESCRIPTION
.B ddate
prints the date in Discordian date format.
Expand Down Expand Up @@ -77,6 +80,9 @@ Celebrate Bureflux
Today's St. Tib's Day, 3162.
.br

.SH OPTIONS
.br -a converts a discordian date into gregorian date

.SH BUGS

.B ddate(1)
Expand All @@ -98,6 +104,8 @@ Major rewrite by Lee H:. O:. Smith, KYTP, aka Andrew Bulhak (acb@dev.null.org)
.br
Gregorian B.C.E. dates fixed by Chaplain Nyan the Wiser, aka Dan Dart (ntw@dandart.co.uk)
.br
Added curse of the greyface by Franz_Nord
.br
Five tons of flax.

.SH DISTRIBUTION POLICY
Expand Down
62 changes: 62 additions & 0 deletions ddate.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
15th of Confusion, 3180:
- call out adherents of the wrong fruit

40th of Confusion, 3184 Franz_Nord
- -a option added the curse of the greyface

FIVE TONS OF FLAX
*/

Expand Down Expand Up @@ -180,6 +183,7 @@ int load_fortunes(char *fn, char *delim, char** result);

struct disc_time convert(int,int);
struct disc_time makeday(int,int,int);
struct disc_time unmakeday(int,int,int);

int
main (int argc, char *argv[]) {
Expand All @@ -204,6 +208,7 @@ main (int argc, char *argv[]) {
switch(argv[pi][1]) {
case 'V':
printf(("%s (%s)\n"), progname, PACKAGE_STRING);
case 'a': goto aneris;
default: goto usage;
}
default: goto thud;
Expand Down Expand Up @@ -240,6 +245,27 @@ main (int argc, char *argv[]) {
format(schwa, fnord, hastur);
printf("%s\n", schwa);

return 0;
aneris:
if (argc-pi==4){
int moe=atoi(argv[pi+1]), larry=atoi(argv[pi+2]), curly=atoi(argv[pi+3]);
hastur = unmakeday(
#ifdef US_FORMAT
moe,larry,
#else
larry,moe,
#endif
curly);
if (hastur.season == -1){
printf("Invalid date -- out of range\n");
return -1;
}
#ifdef US_FORMAT
printf("%d %d %d\n", hastur.season, hastur.day, hastur.year);
#else
printf("%d %d %d\n", hastur.day, hastur.season, hastur.year);
#endif
}
return 0;
}

Expand Down Expand Up @@ -356,6 +382,42 @@ struct disc_time makeday(int imonth,int iday,int iyear) /*i for input */
return funkychickens;
}

struct disc_time unmakeday(int imonth, int iday, int iyear)
{
struct disc_time funkychickens;
int days;
int month;
int cal[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
int leap;

memset(&funkychickens,0,sizeof(funkychickens));

/* basic range checks */
if(iday < 1 || iday > 73 | imonth < 1 || imonth > 5)
{
funkychickens.season = -1;
return funkychickens;
}

month = 0;
days = iday + (imonth - 1) * 73;
funkychickens.year = iyear-1166;
leap = leapp(iyear);
days += leap;

while(days>cal[month] || (leap && month == 1 && days>cal[month]+1)) {
days -= (cal[month] + ((leap && month == 1) ? 1 : 0));
month++;
}

month++;
funkychickens.season = month;
funkychickens.day = days;

// TODO: restumrechnung
return funkychickens;
}

struct disc_time convert(int nday, int nyear)
{ struct disc_time funkychickens;

Expand Down