Cute (.login || .profile) program
Ron Flax
ron at men1.UUCP
Fri Jan 11 04:14:48 AEST 1985
This is a cute little program to put in a uses .login or .profle file
to welcome him/her differently at different times of the day.
The program is called tod.c (time of day):
------C-U-T--H-E-R-E------------------------C-U-T--H-E-R-E--T-O-O------
#include <stdio.h>
#include <time.h>
struct tm *localtime ();
struct tm *loc_time;
main ()
{
long clock;
char tod[5];
int t_hour, t_min, daytime, tnum;
static char *daymsg[] = {"Good Morning!",
"Good Afternoon! Only a few more hours to go.",
"Good Evening! Working late I see.",
"Good Grief! What are you doing on at this hour?",
"I don't know what time it is, do you?"};
time (&clock);
loc_time = localtime (&clock);
t_hour = loc_time->tm_hour;
t_min = loc_time->tm_min;
sprintf (tod, "%2d%02d", t_hour, t_min);
daytime = 5; /* Not sure what time it is? */
tnum = atoi (tod);
if (tnum >= 0500 && tnum <= 1159) /* it's morning */
daytime = 0;
if (tnum >= 1200 && tnum <= 1759) /* it's afternoon */
daytime = 1;
if (tnum >= 1800 && tnum <= 2359) /* it's evening */
daytime = 2;
if (tnum >= 0000 && tnum <= 0459) /* it's late! */
daytime = 3;
printf ("\n\7%s\n", daymsg[daytime]);
}
------C-U-T--H-E-R-E------------------------C-U-T--H-E-R-E--T-O-O------
Ron at men1 (Ron Flax)
MTACCS Engineering Network
..!{seismo,umcp-cs}!{prometh,cal-unix}!men1!ron
More information about the Comp.sources.unix
mailing list