Mikroelektronika MIKROE-442 Datenbogen

Seite von 726
mikroBasic PRO for dsPIC30/33 and PIC24
MikroElektronika
683
Time_epochToDate
Prototype
sub  procedure  Time_epochToDate(dim  e  as  longint,  dim  byref  ts  as 
TimeStruct)
Description Converts the UNIX time to time and date.
Parameters 
e:
 UNIX time (seconds since UNIX epoch) 
ts
: time and date structure for storing conversion output 
Returns
Nothing.
Requires
Nothing.
Example
dim ts2 as TimeStruct
    epoch as longint
...
‘ what date is epoch 1234567890 ?
epoch = 1234567890
Time_epochToDate(epoch,ts2)
Notes
None.
Time_dateDiff
Prototype
sub function Time_dateDiff(dim byref t1, t2 as TimeStruct) as longint
Description This function compares two dates and returns time difference in seconds as a signed long. Result is 
positive if 
t1
 is before 
t2
, result is null if 
t1
 is the same as 
t2
 and result is negative if 
t1
 is after 
t2
.
Parameters -
 t1
: time and date structure (the first comparison parameter) 
-  
t2
: time and date structure (the second comparison parameter)
Parameters None.
Returns
Time difference in seconds as a signed long.
Requires
Nothing.
Example
dim ts1, ts2 as TimeStruct
    diff as longint
...
‘  how  many  seconds  between  these  two  dates  contained  in  ts1  and  ts2 
buffers?
diff = Time_dateDiff(ts1, ts2)
Notes
None.