/*Module/File Name: EDCDT2 */
/**********************************************************/
/* */
/*Function : CEESECS - convert timestamp to seconds */
/* : CEEDATM - convert seconds to timestamp */
/* : */
/*CEESECS is used to convert a timestamp to seconds. */
/*24 hours in seconds is subtracted from */
/*the number of seconds in the original timestamp. */
/*CEEDATM is then used to build a new timestamp */
/*representing the new date and time, 11/01/92 05:22. */
/* */
/**********************************************************/
#include <stdio.h>
#include <string.h>
#include <leawi.h>
#include <ceeedcct.h>
#define TimeStamp "11/02/92 05:22"
#define displacement 24
main ()
{
int User_Input();
_VSTRING Time_Stamp;
_CHAR80 New_TimeStamp;
_VSTRING picstr;
_FLOAT8 Lilian_Seconds;
_FLOAT8 New_Secs;
_FEEDBACK FC;
_INT4 dest=2;
char New_Time[15];
/**************************************************************
The date picstr must be set to match the timestamp format.
**************************************************************/
strncpy (picstr.string,"MM/DD/YY HH:MI",14);
picstr.length = 14;
/*************************************************************/
/* In the following loop the timestamp is converted to Lilian*/
/* seconds. 24 hours in seconds are subtracted from the */
/* Lilian seconds and a new timestamp is created and */
/* displayed. */
/*************************************************************/
strncpy(Time_Stamp.string,TimeStamp,14);
Time_Stamp.length = 14;
/**************************************************************
CEESECS takes the user-entered timestamp Time_Stamp and
returns a double-precision Lilian seconds tally in
Lilian_Seconds
**************************************************************/
CEESECS ( &Time_Stamp, &picstr , &Lilian_Seconds , &FC );
if ( (_FBCHECK (FC , CEE000)) == 0 )
{
/**************************************************************
The displacement variable is subtracted from the Lilian
seconds tally in Lilian_Seconds
**************************************************************/
New_Secs = Lilian_Seconds - displacement * 3600.0;
/*************************************************************
CEEDATM is invoked to get a new timestamp value based on the
new Lilian seconds tally in New_Secs.
*************************************************************/
CEEDATM ( &New_Secs, &picstr , New_TimeStamp , &FC );
if ( (_FBCHECK (FC , CEE000)) == 0 )
{
New_TimeStamp[14] = '\0';
sprintf(New_Time,"%s\0",New_TimeStamp);
printf("%s is the time %i hours before %s\n",
New_Time, displacement, TimeStamp);
}
else
{
printf ( "Error converting Seconds to TimeStamp.\n" );
CEEMSG(&FC, &dest, NULL);
}
}
else
{
printf ( "Error converting TimeStamp to seconds.\n" );
CEEMSG(&FC, &dest, NULL);
}
}