| **Navigation:** [[introduction.htm|Language Reference]] > 3 - Variable Declarations > Data Types >====== TIME (four-byte time) ====== | [[date four byte date .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[64bit integers.htm|{{btn_next_n.gif|Next page}}]] |
| ||
| label | **TIME** | [,**DIM( )**] [,**OVER( )**] [,**NAME( )**] [,**EXTERNAL**] [,**DLL**] [,**STATIC**] [,**THREAD**] [,**AUTO**] |
| | | [,**PRIVATE**] [,**PROTECTED**] |
{{blk2blue.jpg|blk2blue.jpg}}
| **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 four byte date .htm|DATE]]
[[standard time.htm|Standard Time]]
** See Also:** [[prop_timezeroislongone.htm]]
** See Also:** Pragma Time0 [[https://clarionsharp.com/blog/category/clarion9/#:~:text=or%20PRAGMA%20(%E2%80%98define(-,time0,-%3D%3Eon)%E2%80%99)]]
Testing in CW11.1 shows that trying to set a TIME variable to a value of 1
will instead set it to 0