Mikroelektronika MIKROE-738 Datenbogen
![Mikroelektronika](https://files.manualsbrain.com/attachments/e0529b3b58069a916ad7bb89f7e9f5f0eda73421/common/fit/150/50/1b07b99aa3112e022a916b06db07f1f4f211e91d41878452d87c7638b1bf/brand_logo.gif)
mikroC PRO for PIC32
MikroElektronika
655
Library Example
Demonstration of Time library routines usage for time calculations in UNIX time format.
Copy Code To Clipboard
#include “__Time.h”
TimeStruct ts1, ts2;
long epoch;
long diff;
void main() {
ts1.ss = 0;
ts1.mn = 7;
ts1.hh = 17;
ts1.md = 23;
ts1.mo = 5;
ts1.yy = 2006;
/*
* What is the epoch of the date in ts ?
*/
epoch = Time_dateToEpoch(&ts1); // 1148404020
/*
* What date is epoch 1234567890 ?
*/
epoch = 1234567890;
Time_epochToDate(epoch, &ts2); // {0x1E, 0x1F,0x17, 0x0D, 0x04, 0x02, 0x07D9}
/*
* How many seconds there are between these two dates?
*/
diff = Time_dateDiff(&ts1, &ts2); // 86163870
}