a0f5e0898b
which included commits to RCS files with non-trunk default branches. git-svn-id: svn://10.65.10.50/trunk@976 c028cbd2-c16b-5b4b-a496-9718f37d4682
90 lines
1.9 KiB
C
Executable File
90 lines
1.9 KiB
C
Executable File
/***********************************************************************\
|
|
* *
|
|
* DATE.C Copyright (C) 1993 Sequiter Software Inc. *
|
|
* *
|
|
\***********************************************************************/
|
|
/* See User's Manual, page 154 */
|
|
|
|
#include "d4all.h"
|
|
|
|
#ifdef __TURBOC__
|
|
extern unsigned _stklen = 10000;
|
|
#endif
|
|
|
|
int valid_date(char *date)
|
|
{
|
|
long rc;
|
|
rc = date4long(date);
|
|
|
|
if(rc < 1)
|
|
return 0;
|
|
else
|
|
return 1;
|
|
}
|
|
|
|
void how_long_until(int month,int day,char *title)
|
|
{
|
|
char today_standard[9],today[25],date[9],*dow;
|
|
int year,days;
|
|
long julian_today,julian_date;
|
|
|
|
memset(today_standard,NULL
|
|
,sizeof(today_standard));
|
|
memset(today,NULL,sizeof(today));
|
|
memset(date,NULL,sizeof(date));
|
|
|
|
date4today(today_standard);
|
|
date4format(today_standard,today
|
|
,"MMM DD/CCYY");
|
|
|
|
printf("\nToday's date is %s\n",today);
|
|
|
|
|
|
julian_today = date4long(today_standard);
|
|
|
|
year = date4year(today_standard);
|
|
sprintf(date,"%4d%2d%2d",year,month,day);
|
|
|
|
julian_date = date4long(date);
|
|
|
|
if(julian_date < julian_today)
|
|
{
|
|
year ++;
|
|
sprintf(date,"%4d%2d%2d",year,month,day);
|
|
|
|
julian_date = date4long(date);
|
|
}
|
|
|
|
|
|
days = julian_date - julian_today;
|
|
|
|
printf("There are %d days until %s"
|
|
,days,title);
|
|
dow = date4cdow(date);
|
|
|
|
printf("(which is a %s this year)\n",dow);
|
|
|
|
}
|
|
|
|
|
|
void main()
|
|
{
|
|
char birthdate[80],standard[9];
|
|
|
|
|
|
how_long_until(12,25,"Christmas");
|
|
|
|
do
|
|
{
|
|
printf("\nPlease enter your birthdate");
|
|
printf(" in \"DEC 20/1993\" format:");
|
|
gets(birthdate);
|
|
date4init(standard,birthdate,"MMM DD/CCYY");
|
|
|
|
}while(!valid_date(standard));
|
|
|
|
how_long_until(date4month(standard)
|
|
,date4day(standard)
|
|
,"your next birthday");
|
|
}
|