` Printed Icetips Article

Icetips Article



Par2: Parsing Clarion times
2006-10-18 -- Randy Goodhew
 
You can instantly parse a Clarion Standard Time (as a LONG) into its 
time components by using this trick:

BTime      TIME,AUTO
BTovr      GROUP(BTime)
Hundredths   BYTE
Seconds      BYTE
Minutes      BYTE
Hours        BYTE
           END !group
TTime      LONG

  CODE
  BTime = TTime ! auto-converts Clarion Time to Btrieve Time

Now you can get each time component from the over cast array, e.g.
    
  BTovr.Hours
  BTovr.Minutes
  BTovr.Seconds
  BTovr.Hundredths

Note: When Clarion auto-converts a Clarion Standard Time (LONG) to a
Btrieve Time, it automatically subtracts 1, the Midnight bias value.

Also, you can get AM/PM directly from the TTime LONG by using these
EQUATEs to do comparisons:
NoTime         EQUATE(0)
Midnight       EQUATE(1)
Noon           EQUATE(4320001)
MaxTime        EQUATE(8640000)
EndOfAM        EQUATE(Noon - Midnight)
EndOfPM        EQUATE(MaxTime)

Example:

AMPM          STRING(2)
  CODE
  IF TTime => Midnight AND TTime =< EndOfAM
    AMPM = 'AM'
  ELSIF TTime > EndOfAM AND TTime =< EndOfPM
    AMPM = 'PM'
  ELSE
    AMPM = ''
  END !if



Printed November 21, 2024, 7:36 am
This article has been viewed/printed 35255 times.