boolean friday_13th(void) { struct tm *lt = getlt(); return (boolean) (lt->tm_wday == 5 /* friday */ && lt->tm_mday == 13); }
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; }
int night() { int hour = getlt()->tm_hour; return (hour < 6 || hour > 21); }
bool night(void) { int hour = getlt()->tm_hour; return (hour < 6 || hour > 21); }
int night(void) { int hour = getlt()->tm_hour; return hour < 6 || hour > 21; }
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); }
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); }
/* * 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 ); }
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 ); }
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; }
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); }
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; }
int first_of_month (void) { struct tm *lt = getlt(); return (int)((lt->tm_mday == 1)); }
/* Returns current day of month (1-31) */ int getmday(void) { return(getlt()->tm_mday); }
int getyear(void) { return 1900 + getlt()->tm_year; }
int midnight(void) { return (getlt()->tm_hour == 0); }
/* Returns current month (1-12, 1 = January) */ int getmonth(void) { return(1 + getlt()->tm_mon); }
int getyear(void) { return (1900 + getlt()->tm_year); }
night() { register int hour = getlt()->tm_hour; return(hour < 6 || hour > 21); }
int friday_13th (void) { struct tm *lt = getlt(); return((int)((lt->tm_wday == 5) /* friday */ && (lt->tm_mday == 13))); }
midnight() { return(getlt()->tm_hour == 0); }
int halloween (void) { struct tm *lt = getlt(); return((int)((lt->tm_mday == 31) && (lt->tm_mon == 9))); }
int night (void) { int hour = getlt()->tm_hour; return((hour < 6) || (hour > 21)); }
getyear() { return(1900 + getlt()->tm_year); }
int december (void) { struct tm *lt = getlt(); return((int)(lt->tm_mon == 11)); }
int xmas (void) { struct tm *lt = getlt(); return((int)((lt->tm_mday == 25) && (lt->tm_mon == 11))); }
int midnight(void) { return getlt()->tm_hour == 0; }
int midnight_close (void) { int hour = getlt()->tm_hour; return (hour > 23); }