clocktime.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright (c) 1996 by Sun Microsystems, Inc.
* All Rights Reserved.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* clocktime - compute the NTP date from a day of year, hour, minute
* and second.
*/
#include "ntp_fp.h"
#include "ntp_unixtime.h"
#include "ntp_stdlib.h"
/*
* Hacks to avoid excercising the multiplier. I have no pride.
*/
/*
* Two days, in seconds.
*/
/*
* We demand that the time be within CLOSETIME seconds of the receive
* time stamp. This is about 4 hours, which hopefully should be
* wide enough to collect most data, while close enough to keep things
* from getting confused.
*/
int
int yday;
int hour;
int minute;
int second;
int tzoff;
{
register long tmp;
/*
* Compute the offset into the year in seconds. Note that
* this could come out to be a negative number.
*/
/*
* Initialize yearstart, if necessary.
*/
if (yst == 0) {
}
/*
* Now the fun begins. We demand that the received clock time
* be within CLOSETIME of the receive timestamp, but
* there is uncertainty about the year the timestamp is in.
* Use the current year start for the first check, this should
* work most of the time.
*/
return 1;
}
/*
* Trouble. Next check is to see if the year rolled over and, if
* so, try again with the new year's start.
*/
return 1;
}
}
/*
* Here we know the year start matches the current system
* time. One remaining possibility is that the time code
* is in the year previous to that of the system time. This
* is only worth checking if the receive timestamp is less
* than a couple of days into the new year.
*/
return 1;
}
}
}
/*
* One last possibility is that the time stamp is in the year
* following the year the system is in. Try this one before
* giving up.
*/
return 1;
}
}
/*
* Give it up.
*/
return 0;
}