home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
disk_20.zip
/
BETDATE.ZIP
/
FOSE0007.PRG
< prev
Wrap
Text File
|
1988-02-02
|
3KB
|
158 lines
CLEAR
CLEAR ALL
SET TALK OFF
SET STATUS OFF
SET SCOREBOARD OFF
@ 4,5 TO 18,74 DOUBLE
DO WHILE .T.
x = 0
y = 0
begindate = CTOD('12/25/87')
enddate = CTOD([])
@ 8,10 SAY " Months = " + STR(X)
@ 9,10 SAY " Days = " + STR(Y)
@ 14,10 SAY " Months = " + STR(X)
@ 15,10 SAY " Days = " + STR(Y)
@ 10,10 SAY "Beginning Date = " + DTOC(begindate)
@ 11,10 SAY " Ending Date = " GET enddate PICTURE "@D"
READ
DO betdat WITH x,y,begindate,enddate
@ 14,10 SAY " Months = " + STR(X)
@ 15,10 SAY " Days = " + STR(Y)
@ 19,1 SAY ""
WAIT TO stopit
IF stopit = "X"
EXIT
ENDIF
ENDDO
CLEAR
TEXT
* Program..: Betdates.prg
* Author...: Martin Schiff
* Date.....: February 6,1987
* Notice...: Custom Data Solutions, 1987, All rights reserved.
* Notes....: Betdates.prg
*
* This routine will take as input a start date and a finish date, and return
* the number of months and additional days between the 2 dates. The
* routine actually figures the number of nights since it is for the travel
* industry, but could be easily modified to measure the span including the
* start and finish date. The number of months is returned in tMONTHS, and
* the number of days extra in tDAYS.
*
* If you run the program with talk set on, and you watch the dates change
* using a date with 31 for the you will notice that as the program executes
* you can see the last date of the month change from 31 to 30 and back, and
* to 28 or 29 in February.
*
* This routine may be incorporated in your programs as long as the header
* remains intact.
ENDTEXT
WAIT
CLEAR
TEXT
PARAMETERS tMONTHS,tDAYS,START,FINISH
holdate=start
prevhold=start
dofdep=finish && dofdep -- date of departure
periods=0
xdays=0
needtest=.f.
if day(start)>28
needtest=.t.
endif
changed=.f.
day=substr(dtoc(holdate),4,2)
oldday=day
ENDTEXT
WAIT
CLEAR
TEXT
do while holdate < dofdep
prevhold=holdate
if changed && if we have changed from the original day
day=oldday && change it back
else
day=substr(dtoc(holdate),4,2)
endif
month=substr(dtoc(holdate),1,2)
year=substr(dtoc(holdate),7,2)
ENDTEXT
WAIT
CLEAR
TEXT
** The following routine moves you to a date one month from the date stored
** in holdate.
if month = '12'
month='01'
year=str((val(year)+1),2)
else
if needtest && the day of the month is > 28
if val(month)=1
changed=.t.
oldday=day
if mod(year(holdate),4)=0 && if it is a leapyear
day='29'
else
day='28'
endif
else
ENDTEXT
WAIT
CLEAR
TEXT
if val(day)=31
m=val(month)
if m=3 .or. m=5 .or. m=8 .or. m=10 && if prev month had 30
changed=.t. && days
oldday=day
day='30'
endif
endif
endif
endif
month=str((val(month)+1),2)
endif
ENDTEXT
WAIT
CLEAR
TEXT
holdate=ctod(month+'/'+day+'/'+year)
if holdate <= dofdep
periods=periods+1
else
xdays=dofdep-prevhold
endif
enddo
tmonths=periods
tdays=xdays
RETURN
ENDTEXT
WAIT
CLEAR
SET STATUS ON
SET SCOREBOARD OFF
SET STATUS ON
SET TALK ON