OSF DCE Application Development Guide--Core Components

DTS API Routines Programming Example
/* Print out a utc structure in ISO text format.
*/
void PrintTime(utcTime)
struct utc *utcTime;
{
char string[50];
/* Break up the time string.
*/
if (utc_ascgmtime(string, /* Out: Converted time */
50, /* In: String length */
utcTime)) /* In: Time to convert */
exit(1);
printf("%s\n",string);
}
/* Prompt the user to enter time coordinates. Store the
* coordinates in a tm structure and then convert the tm
* structure to a utc structure.
*/
void ReadTime(utcTime)
struct utc *utcTime;
{
struct tm tmTime,tmInacc;
(void)memset((void *)&tmTime, 0, sizeof(tmTime));
(void)memset((void *)&tmInacc, 0, sizeof(tmInacc));
(void)printf("Year? ");
(void)scanf("%d",&tmTime.tm_year);
tmTime.tm_year -= 1900;
(void)printf("Month? ");
(void)scanf("%d",&tmTime.tm_mon);
tmTime.tm_mon -= 1;
(void)printf("Day? ");
(void)scanf("%d",&tmTime.tm_mday);
(void)printf("Hour? ");
(void)scanf("%d",&tmTime.tm_hour);
(void)printf("Minute? ");
(void)scanf("%d",&tmTime.tm_min);
(void)printf("Inacc Secs? ");
(void)scanf("%d",&tmInacc.tm_sec);
if (utc_mkanytime(utcTime,
&tmTime,
(long)0,
&tmInacc,
(long)0,
(long)0))
exit(1);
}
124245 Tandem Computers Incorporated 213