Navigation:  Reference > Functions >

CurrentTime()

Print this Topic Previous pageReturn to chapter overviewNext page

 

TIME()

 

PURPOSE

This function will return the current system time.

 

NO OTHER PARTS

 

RETURN TYPE - T

 

COMMENTS

This is the time returned by Windows as the current time.

 

EXAMPLE

define cur_time type T size 10

cur_time = time()

 

SEE ALSO

DATE()   Convert to Date CTOD() Convert to time CTOT()   TIME GET SET  Convert time to record TTOR()  Covert time to number TTOF() Convert time to string TTOC()

TIME() YEAR() Date Command  Date to Record DTOR()  Convert date to Character DTOC() Days in month DAY_IN_MONTH

Increment the Month INC_MONTH DayMonthyear DMY()  Month Day Year MDY()

Charicter of month CMNTH()  Charicter to day of week CDOW()

 

Examples if using time and conversion

define cur_dec_time type n size 5 dec 2

cur_dec_time = TTOF(time())/3600     // current decimal time

define cur_rec_time = TTOR(time()/86400 //curent time in seconds..

 

Here is a sample if what I had to do in a program..  Only Putting this in here for reference.

define ok type l

   define cur_dec_time,last_dec_time,ET_dec type n size 5 dec 2

func chktime

     if last_date = 0 then last_date = ctod('01/01/2010')

     //msg 'Test time'

     cur_dec_time = TTOF(time())/3600     // current decimal time

     last_dec_time = TTOF(last_time)/3600  // last visit decimal time

     et_dec = cur_dec_time - last_dec_time  //Elapst time decimal

     //msg et_dec

   // need to get num days

   define days type i

   days = date() - last_date

   //msg 'days: '+days

     if days > 2   // its been more then 2 days we let them in

       ok = .t.

       ret .t.

     endif

     if days = 1

        //msg 'two day'

        //msg 'ent_dec:'+et_dec

        //msg 'enter hours:'+ enterhrs

        // there are 2 days here

     //example : 24 -       8       +      1         = 17 hrs

        et_dec = 24 - last_dec_time + cur_dec_time

        //msg 'one day'

        //msg 'ent_dec:'+et_dec

        //msg 'enter hours:'+enterhrs

        if et_dec < ENTERHRS

           //msg 'et_dec < ENTERHRS'

           if et_dec < GRACE/60   // check grace period

             //msg 'grace period true'

             graceok = .t.

             ok = .t.

             ret .t.

           else

             //msg 'grace period false'

             graceok = .f.

           endif

        endif

        if et_dec > ENTERHRS

           //msg 'et_dec < ENTERHRS #2'

           ok = .t.

           ret .t.

        else

        //msg 'everthing fails so we dont let them in.'

           ok = .f.

           ret .t.

        endif

      endif

 

     if days = 0

      // only one day

      et_dec = cur_dec_time - last_dec_time

      //msg 'one day'

      //msg 'ent_dec:'+et_dec

      //msg 'enter hours:'+enterhrs

      if et_dec < ENTERHRS

        //msg 'et_dec < ENTERHRS'

        if et_dec < GRACE/60   // check grace period

          // msg 'grace period true'

           graceok = .t.

           ok = .t.

           ret .t.   // we let then in

        else

           //msg 'grace period false'

           graceok = .f.

 

        endif

      endif

        if et_dec > ENTERHRS

           //msg 'et_dec > ENTERHRS #2'

           ok = .t.

           ret .t.

        else

        //msg 'everthing fails so we dont let them in.'

           ok = .f.

           ret .t.

        endif

      endif

 

Another Example :

 

Assume File has record with Starting Time and Date fields: fld_starttime, fld_startdate
 
define PostTime,TimeDiff type T size 10
define PostDate type D size 8
 
btnTimePunch.click:
GetPostTime
GetRecord
if PostDate < fld_startdate
msg 'Your start date must be less than or equal to your stop date'
ret
endif
TimeDiff = iif(PostDate = fld_startdate,RtoT(TtoR(PostTime)-TtoR(fld_starttime)),RToT(86400-TtoR(fld_starttime)+TtoR(PostTime)))
// Stop at 3:00pm Start at 1:00pm 54000-46800 = 7200secs = 2hrs (Same Day)
// Stop at 1:00am Start at 11:00pm 86400-82800+3600 = 7200secs = 2hrs (Day Crossed-over)
ret
 
 
cmd GetPostTime
PostDate = Date()
PostTime = Time()
if PostDate <> Date() // Date can advance if when time is 11:59:59
PostDate = Date() // for the time it takes to execute statement
PostTime = Time() // Therefor re-get Date and Time
endif
ret
 
cmd GetRecord
find record based on your criteria
ret
 

 

 

 

 

 

 


Page url: http://www.cassoftware.com/tas/manual/currenttime().htm