/* test_day_in_week.f -- translated by f2c (version 20100827).
   You must link the resulting object file with libf2c:
	on Microsoft Windows system, link with libf2c.lib;
	on Linux or Unix systems, link with .../path/to/libf2c.a -lm
	or, if you install libf2c.a in a standard place, with -lf2c -lm
	-- in that order, at the end of the command line, as in
		cc *.o -lf2c -lm
	Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,

		http://www.netlib.org/f2c/libf2c.zip
*/

#include "f2c.h"

/* Table of constant values */

static integer c__1 = 1;

/* Main program */ int MAIN__(void)
{
    /* Format strings */
    static char fmt_100[] = "(a,i3)";
    static char fmt_200[] = "(a,1x,i4)";

    /* System generated locals */
    integer i__1;

    /* Builtin functions */
    integer s_wsle(cilist *), e_wsle(void), s_wsfe(cilist *), do_fio(integer *
	    , char *, ftnlen), e_wsfe(void), s_cmp(char *, char *, ftnlen, 
	    ftnlen);
    /* Subroutine */ int s_stop(char *, ftnlen);

    /* Local variables */
    extern /* Subroutine */ int cp_en_month_name__(integer *, char *, integer 
	    *, ftnlen), cp_nbday_in_month__(integer *, integer *, integer *);
    static char cday[9];
    static integer iday, idow, nbcha, nbday, iyear;
    extern /* Subroutine */ int cp_en_day_name__(integer *, char *, integer *,
	     ftnlen);
    static char cmonth[9];
    static integer imonth;
    extern /* Subroutine */ int cv_date_to_dotw__(integer *, integer *, 
	    integer *, integer *);

    /* Fortran I/O blocks */
    static cilist io___1 = { 0, 6, 0, 0, 0 };
    static cilist io___2 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___3 = { 0, 6, 0, 0, 0 };
    static cilist io___4 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___5 = { 0, 6, 0, 0, 0 };
    static cilist io___11 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___12 = { 0, 6, 0, fmt_200, 0 };
    static cilist io___13 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___17 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___18 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___19 = { 0, 6, 0, 0, 0 };
    static cilist io___20 = { 0, 6, 0, fmt_100, 0 };
    static cilist io___21 = { 0, 6, 0, 0, 0 };



/*     ***************************************************************0** */
/* *   Test_Day_in_Week: compute day in a week, to check with calendars. */
/*     P. Robert, Dec 2006 */
/*     ***************************************************************0** */


    s_wsle(&io___1);
    e_wsle();
    s_wsfe(&io___2);
    do_fio(&c__1, "************", (ftnlen)12);
    e_wsfe();
    s_wsle(&io___3);
    e_wsle();
    s_wsfe(&io___4);
    do_fio(&c__1, "doweek: compute day in the week for given year", (ftnlen)
	    46);
    e_wsfe();
    s_wsle(&io___5);
    e_wsle();

    for (iyear = 1999; iyear <= 2018; ++iyear) {

	for (imonth = 1; imonth <= 12; ++imonth) {

	    cp_en_month_name__(&imonth, cmonth, &nbcha, (ftnlen)9);
	    cp_nbday_in_month__(&iyear, &imonth, &nbday);

	    s_wsfe(&io___11);
	    do_fio(&c__1, "--------------", (ftnlen)14);
	    e_wsfe();
	    s_wsfe(&io___12);
	    do_fio(&c__1, cmonth, (ftnlen)9);
	    do_fio(&c__1, (char *)&iyear, (ftnlen)sizeof(integer));
	    e_wsfe();
	    s_wsfe(&io___13);
	    do_fio(&c__1, "--------------", (ftnlen)14);
	    e_wsfe();

	    i__1 = nbday;
	    for (iday = 1; iday <= i__1; ++iday) {

		cv_date_to_dotw__(&iyear, &imonth, &iday, &idow);
		cp_en_day_name__(&idow, cday, &nbcha, (ftnlen)9);

		s_wsfe(&io___17);
		do_fio(&c__1, cday, (ftnlen)9);
		do_fio(&c__1, (char *)&iday, (ftnlen)sizeof(integer));
		e_wsfe();
		if (s_cmp(cday, "Sunday", (ftnlen)6, (ftnlen)6) == 0) {
		    s_wsfe(&io___18);
		    do_fio(&c__1, " ", (ftnlen)1);
		    e_wsfe();
		}

/* L10: */
	    }
	}
    }


    s_wsle(&io___19);
    e_wsle();
    s_wsfe(&io___20);
    do_fio(&c__1, "************", (ftnlen)12);
    e_wsfe();
    s_wsle(&io___21);
    e_wsle();
    s_stop("test_day_in_week.exe: normal termination", (ftnlen)40);
    return 0;
} /* MAIN__ */

/* Main program alias */ int test_day_in_week__ () { MAIN__ (); return 0; }
