home *** CD-ROM | disk | FTP | other *** search
- /*
- * Program to set the time on the DTK clock/calendar board.
- * (C) Copyright 1989 Richard B. Wales. All Rights Reserved.
- */
-
- #include <stdio.h>
- #include "clkdefs.h"
-
-
- static char copyright[] =
- "SAVECLK -- Set DTK clock/calendar board, version 1.10\r\n\
- (C) Copyright 1989 Richard B. Wales";
-
-
- void main ()
- { struct clockval *cv;
- struct date date, *da;
- struct time time, *ti;
-
- /*
- * Identify the program.
- */
- printf ("%s\n", copyright);
-
- /*
- * Get the system date and time.
- */
- gettime (&time); getdate (&date);
-
- /*
- * Transform the date/time into the clock structure.
- */
- time_to_clock (&date, &time, &cv);
- if (cv == NULL_CLOCK)
- { printf ("Garbled system date/time\n");
- exit (1);
- }
-
- /*
- * Set the clock/calendar.
- */
- if (write_clock (cv) == NULL_CLOCK)
- { printf ("Error setting clock\n");
- exit (1);
- }
-
- /*
- * Announce the new date and time on the clock board.
- */
- cv = read_clock ();
- if (cv == NULL_CLOCK)
- { printf ("Error reading back clock\n");
- exit (1);
- }
- clock_to_time (cv, &da, &ti);
- if (da == NULL_DATE || ti == NULL_TIME)
- { printf ("Garbled date/time from clock\n");
- exit (1);
- }
- printf ("Clock board set to %02d/%02d/%02d %02d:%02d:%02d\n",
- da->da_mon, da->da_day, da->da_year % 100,
- ti->ti_hour, ti->ti_min, ti->ti_sec);
-
- /*
- * That's all.
- */
- exit (0);
- }