> Thanks Michel - but what if the user enters
> 44:88. I will have to set up a VALID to
> check for user entry. I was hoping there was
> function that checks for a valid time. I guess
> I will have to write my own..I must have written
> at least 1000 functions maybe more...rob
Ok, try this one. It works for fpd2.6, but converting it to VFP should
take you couple of minutes. The _tim parameter should contain 4 digits,
not necessarily filled (i.e. "7 " will get converted into "0700").
"Poruka" means "message". You should call this by ref, so _tim will get
corrected (reformatted, and times like 1375 converted to 1415). Varr()
is the "variable read" in fpd2.6 - if you make a time class out of this,
replace it with this.value.
para _tim, z5
C_1h =''
C_24h ='On Earth, day has 24 hours.'
C_letit ='Let it go as '
C_min =' minutes?'
C_neg ='Negative hours?'
* if z5 - round to 5 minutes
* sati=hours, minuta=minutes
priv _noparams, sati, minuta, _varr
_noparams= para()=0
if _noparams
_tim=eval(varr())
endif
sati=val(left(_tim,2))
minuta=val(right(_tim,2))
_tim=tran(sati,'@L 99')+tran(minuta,'@L 99')
_vld=.t.
do case
case sati < 0
_vld=poruka(c_neg)
case _tim="2400"
case (sati=24 and minuta > 0) or sati>23
_vld=poruka(c_24h)
case minuta=60
_tim=tran(sati+1,'@L 99')+'00'
_vld=poruka(c_letit+tran(_tim,'@R 99:99')) or .t.
case !betw(minuta,0,59)
_vld=poruka(c_1h+str(minuta,2,0)+c_min)
case minuta % 5 # 0 and z5
minuta = round(minuta*2,-1)/2
if minuta=60
_tim=tran(sati+1,'@L 99')+'00'
else
_tim=stuff(_tim,3,2,tran(minuta,'@L 99'))
endif
endc
retu _vld