Navigation: Language Reference > 3 - Variable Declarations > Data Types >====== TIME (four-byte time) ====== | ![]() ![]() ![]() |
label | TIME | [,DIM( )] [,OVER( )] [,NAME( )] [,EXTERNAL] [,DLL] [,STATIC] [,THREAD] [,AUTO] |
[,PRIVATE] [,PROTECTED] |
TIME | A four-byte time. |
Format: hh mm ss hs
| …. | …. | …. | …. |
Bits: 31 23 15 7 0
Range:
hours: 0 to 23
minutes: 0 to 59
seconds: 0 to 59
seconds/100: 0 to 99
DIM | Dimension the variable as an array. |
OVER | Share a memory location with another variable. |
NAME | Specify an alternate, “external” name for the field. |
EXTERNAL | Specify the variable is defined, and its memory is allocated, in an external library. Not valid within FILE, QUEUE, or GROUP declarations. |
DLL | Specify the variable is defined in a .DLL. This is required in addition to the EXTERNAL attribute. |
STATIC | Specify the variable's memory is permanently allocated. |
THREAD | Specify memory for the variable is allocated once for each execution thread. Also implicitly adds the STATIC attribute on Procedure Local data. |
AUTO | Specify the variable has no initial value. |
PRIVATE | Specify the variable is not visible outside the module containing the CLASS methods. Valid only in a CLASS. |
PROTECTED | Specify the variable is not visible outside base CLASS and derived CLASS methods. Valid only in a CLASS. |
TIME declares a four byte time variable. This format matches the “TIME” field type used by the Pervasive Btrieve file system. A TIME used in a numeric expression is converted to the number of hundredths of a second elapsed since midnight (Clarion Standard Time - usually stored as a LONG). TIME fields should be used to achieve compatibility with outside files or procedures.
Example:
ChkoutTime TIME !Declare checkout time field
OtherTime TIME,OVER(CheckoutTime) !Declare field over time field
ContactTime TIME,DIM(4) !Array of 4 time fields
ExampleFile FILE,DRIVER('Btrieve') !Declare a file
Record RECORD
TimeRecd TIME,NAME('TimeField') !Declare with external name
END
END
While a TIME data type has a unique long integer, the internal format will automatically convert it to or from a Clarion Standard Time.
Here are some example of functions frequently needed. The first is normally done with FORMAT and String functions. The second is done with Multiplication.
GetTime PROCEDURE(LONG ClaTime, *LONG OutHour, *LONG OutMin, *LONG OutSec,<;*LONG OutHS>) |
BTTime TIME,AUTO |
BT GROUP,OVER(BTTime) !Note Little Endian reversal |
HS BYTE |
Sec BYTE |
Min BYTE |
Hour BYTE |
END |
CODE |
BTTime = ClaTime ! Convert LONG (Clarion Standard Time) to a Btrieve Time HHSSMMHH with Cla$storebtdate |
IF ~OMITTED(5) THEN OutHS = BT.HS. |
OutSec = BT.Sec |
OutMin = BT.Min |
OutHour = BT.Hour |
RETURN |
!—————————————- |
Time PROCEDURE(LONG InHour, LONG InMin, LONG InSec,LONG InHS=0)!LONG |
BTTime TIME,AUTO |
BT GROUP,OVER(BTTime) !Note Little Endian reversal |
HS BYTE |
Sec BYTE |
Min BYTE |
Hour BYTE |
END |
CODE |
BT.HS = InHS |
BT.Sec = InSec |
BT.Min = InMin |
BT.Hour = InHour |
RETURN BTTime !Converts TIME to (Clarion Standard Time) |
!———————————- |
Time2 PROCEDURE(LONG InHour, LONG InMin, LONG InSec,LONG InHS=0)!LONG |
CTime LONG,AUTO |
CODE |
CTime = InHour * 60 * 6000 + InMin * 6000 + InSec * 100 + InHS |
IF CTime THEN CTime += 1. |
RETURN CTime |
See Also: DATE