/*Module/File Name: EDCDT1 */
/*********************************************************/
/* */
/*Function : CEESECS - convert timestamp to seconds*/
/* */
/*This example calls the LE CEESECS callable service */
/* to compute the hour number of numbers between the */
/* timestamps 11/02/92 05:22 and 11/02/92 17:22. The */
/* program responds that 36 hours has elapsed. */
/*********************************************************/
#include <stdio.h>
#include <string.h>
#include <leawi.h>
#include <ceeedcct.h>
main ()
{
_VSTRING StartTime;
_VSTRING EndTime;
_VSTRING picstr;
_FLOAT8 Start_Secs;
_FLOAT8 End_Secs;
_FLOAT8 Elapsed_Time;
_FEEDBACK FC;
_INT4 dest=2;
/***************************************************************
The date picstr must be set to match the timestamp format.
**************************************************************/
strncpy (picstr.string,"MM/DD/YY HH:MI",14);
picstr.length = 14;
strncpy(StartTime.string,"11/02/92 05:22",14);
StartTime.length = 14;
strncpy(EndTime.string,"11/03/92 17:22",14);
EndTime.length = 14;
/**************************************************************
CEESECS takes the start time and returns
a double-precision Lilian seconds tally in Start_Secs.
**************************************************************/
CEESECS ( &StartTime, &picstr , &Start_Secs , &FC );
if ( _FBCHECK (FC , CEE000) == 0 )
{
/**************************************************************
CEESECS takes the end time and returns
a double-precision Lilian seconds tally in End_Secs.
**************************************************************/
CEESECS ( &EndTime, &picstr , &End_Secs , &FC );
if ( _FBCHECK (FC , CEE000) == 0 )
{
Elapsed_Time = (End_Secs - Start_Secs)/3600.0;
printf("%4.2f hours have elapsed between %s and %s.\n",
Elapsed_Time, StartTime.string, EndTime.string);
}
else
{
printf ( "Error converting TimeStamp to seconds.\n" );
CEEMSG(&FC, &dest, NULL);
}
}
else
{
printf ( "Error converting TimeStamp to seconds.\n" );
CEEMSG(&FC, &dest, NULL);
}
}