Exemple #1
0
boolean
friday_13th(void)
{
    struct tm *lt = getlt();

    return (boolean) (lt->tm_wday == 5 /* friday */  && lt->tm_mday == 13);
}
Exemple #2
0
const char* getdatestr (void)
{
    static char datestr[7];
    struct tm *lt = getlt();
    sprintf(datestr, "%02d%02d%02d", lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday);
    return datestr;
}
Exemple #3
0
int
night()
{
	int             hour = getlt()->tm_hour;

	return (hour < 6 || hour > 21);
}
Exemple #4
0
bool
night(void)
{
	int hour = getlt()->tm_hour;

	return (hour < 6 || hour > 21);
}
Exemple #5
0
int
night(void)
{
    int hour = getlt()->tm_hour;

    return hour < 6 || hour > 21;
}
Exemple #6
0
char           *
getdatestr(void)
{
	static char     datestr[7];
	struct tm      *lt = getlt();

	(void) snprintf(datestr, sizeof(datestr), "%02d%02d%02d",
		       lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday);
	return (datestr);
}
Exemple #7
0
char *
getdate()
{
	static char datestr[7];
	register struct tm *lt = getlt();

	Sprintf(datestr, "%2d%2d%2d",
		lt->tm_year, lt->tm_mon + 1, lt->tm_mday);
	if(datestr[2] == ' ') datestr[2] = '0';
	if(datestr[4] == ' ') datestr[4] = '0';
	return(datestr);
}
Exemple #8
0
/*
 * moon period = 29.53058 days ~= 30, year = 365.2422 days
 * days moon phase advances on first day of year compared to preceding year
 *      = 365.2422 - 12*29.53058 ~= 11
 * years in Metonic cycle (time until same phases fall on the same days of
 *      the month) = 18.6 ~= 19
 * moon phase on first day of year (epact) ~= (11*(year%19) + 29) % 30
 *      (29 as initial condition)
 * current phase in days = first day phase + days elapsed in year
 * 6 moons ~= 177 days
 * 177 ~= 8 reported phases * 22
 * + 11/22 for rounding
 */
int phase_of_the_moon (void)            /* 0-7, with 0: new, 4: full */
{
        struct tm *lt = getlt();
        int epact, diy, goldn;

        diy = lt->tm_yday;
        goldn = (lt->tm_year % 19) + 1;
        epact = (11 * goldn + 18) % 30;
        if ((epact == 25 && goldn > 11) || epact == 24)
                epact++;

        return( (((((diy + epact) * 6) + 11) % 177) / 22) & 7 );
}
Exemple #9
0
phase_of_the_moon()			/* 0-7, with 0: new, 4: full */
{   /* moon period: 29.5306 days */
    /* year: 365.2422 days */
    register struct tm *lt = getlt();
    register int epact, diy, golden;

    diy = lt->tm_yday;
    golden = (lt->tm_year % 19) + 1;
    epact = (11 * golden + 18) % 30;
    if ((epact == 25 && golden > 11) || epact == 24)
        epact++;

    return( (((((diy + epact) * 6) + 11) % 177) / 22) & 7 );
}
Exemple #10
0
int phase_of_the_moon(void)
{
    // 0-7, with 0: new, 4: full moon period: 29.5306 days. year: 365.2422 days
    struct tm *lt = getlt();
    int epact, diy, golden;

    diy = lt->tm_yday;
    golden = (lt->tm_year % 19) + 1;
    epact = (11 * golden + 18) % 30;
    if ((epact == 25 && golden > 11) || epact == 24)
	epact++;

    return (((((diy + epact) * 6) + 11) % 177) / 22) & 7;
}
Exemple #11
0
char *
getdate()
{
#ifdef LINT	/* static char datestr[7]; */
	char datestr[7];
#else
	static char datestr[7];
#endif
	register struct tm *lt = getlt();

	Sprintf(datestr, "%2d%2d%2d",
		lt->tm_year, lt->tm_mon + 1, lt->tm_mday);
	if(datestr[2] == ' ') datestr[2] = '0';
	if(datestr[4] == ' ') datestr[4] = '0';
	return(datestr);
}
Exemple #12
0
long yyyymmdd(time_t date)
{
	long datenum;
	struct tm *lt;

	if (date == 0)
		lt = getlt();
	else
		lt = localtime(&date);

	/* just in case somebody's localtime supplies (year % 100)
	   rather than the expected (year - 1900) */
	if (lt->tm_year < 70)
	    datenum = (long)lt->tm_year + 2000L;
	else
	    datenum = (long)lt->tm_year + 1900L;
	/* yyyy --> yyyymm */
	datenum = datenum * 100L + (long)(lt->tm_mon + 1);
	/* yyyymm --> yyyymmdd */
	datenum = datenum * 100L + (long)lt->tm_mday;
	return datenum;
}
Exemple #13
0
int first_of_month (void)
{
        struct tm *lt = getlt();

        return (int)((lt->tm_mday == 1));
}
Exemple #14
0
/* Returns current day of month (1-31) */
int
getmday(void)
{
    return(getlt()->tm_mday);
}
Exemple #15
0
int
getyear(void)
{
    return 1900 + getlt()->tm_year;
}
Exemple #16
0
int
midnight(void)
{
	return (getlt()->tm_hour == 0);
}
Exemple #17
0
/* Returns current month (1-12, 1 = January) */
int
getmonth(void)
{
    return(1 + getlt()->tm_mon);
}
Exemple #18
0
int
getyear(void)
{
	return (1900 + getlt()->tm_year);
}
Exemple #19
0
night()
{
    register int hour = getlt()->tm_hour;

    return(hour < 6 || hour > 21);
}
Exemple #20
0
int friday_13th (void)
{
        struct tm *lt = getlt();

        return((int)((lt->tm_wday == 5) /* friday */ && (lt->tm_mday == 13)));
}
Exemple #21
0
midnight()
{
    return(getlt()->tm_hour == 0);
}
Exemple #22
0
int halloween (void)
{
        struct tm *lt = getlt();

        return((int)((lt->tm_mday == 31) && (lt->tm_mon == 9)));
}
Exemple #23
0
int night (void)
{
        int hour = getlt()->tm_hour;

        return((hour < 6) || (hour > 21));
}
Exemple #24
0
getyear()
{
    return(1900 + getlt()->tm_year);
}
Exemple #25
0
int december (void)
{
        struct tm *lt = getlt();

        return((int)(lt->tm_mon == 11));
}
Exemple #26
0
int xmas (void)
{
        struct tm *lt = getlt();

        return((int)((lt->tm_mday == 25) && (lt->tm_mon == 11)));
}
Exemple #27
0
int
midnight(void)
{
    return getlt()->tm_hour == 0;
}
Exemple #28
0
int midnight_close (void)
{
        int hour = getlt()->tm_hour;

        return (hour > 23);
}