home *** CD-ROM | disk | FTP | other *** search
/ nisttime.carsoncity.k12.mi.us / nisttime.carsoncity.k12.mi.us.tar / nisttime.carsoncity.k12.mi.us / pub / lockclock / putleap.c < prev    next >
C/C++ Source or Header  |  1996-11-18  |  993b  |  35 lines

  1. void putleap(lsflag)
  2. int lsflag;
  3. {
  4. #include <stdio.h>
  5. #include <sys/time.h>
  6. /*
  7.     this subroutine is called when the ACTS system has
  8.     a non-zero leap-second flag indicating that a leap
  9.     second is approaching at the end of this month.
  10.  
  11.     this subroutine writes a message giving the month
  12.     and year of the leap second and the type of leap
  13.     second (+ or -) as specified by the ACTS system.
  14.     lsflag is normally +1, but may be +10 if the leap
  15.     second notification is on the last day of the month.
  16.     likewise, if the flag value would have been +2, it 
  17.     will be +20 on the last day of the month to show that
  18.     the event is today.
  19. */
  20. FILE *iop,*fopen();
  21. struct timeval tvv;
  22. struct tm  *gv;
  23. void lockerr();        /*writes error message to file*/
  24.     if(lsflag >= 10) lsflag /= 10;
  25.     gettimeofday(&tvv,0);
  26.     gv=gmtime(&tvv);
  27.     if( (iop=fopen("leap.dat","wt") ) == NULL) 
  28.        {
  29.        lockerr("Cannot open file leap.dat in putleap");
  30.        return;
  31.     }
  32.     fprintf(iop,"%d %d %d",gv->tm_mon+1,gv->tm_year,lsflag);
  33.     fclose(iop);
  34. }
  35.