Search
SailfishOS Open Build Service
>
Projects
>
sailfishos
:
chum
:
testing
>
ddate
> PR16.diff
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File PR16.diff of Package ddate
diff --git a/ddate.1 b/ddate.1 index c340578..035b92e 100644 --- a/ddate.1 +++ b/ddate.1 @@ -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. @@ -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) @@ -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 diff --git a/ddate.c b/ddate.c index c0a6bf3..97042d7 100644 --- a/ddate.c +++ b/ddate.c @@ -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 */ @@ -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[]) { @@ -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; @@ -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; } @@ -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;