JohnR2010,
I think it's in my calculation of #Leap Years since 1900 but I need to test it for when Feb 29th rolls over. I think there needs to be another check in February to see if the current year is a leap year. In the current Spinneret code it checks for previous leap years, thus where the one day difference error is occurring ... when the current year is a leap year.
I have not tested this in the Spinneret yet, but only in the Perl code that I originally used to debug in the first place. I still need to implement a check for Feb rollover and if the current year is a leap year or not.
Here is the Perl code if you or anyone is interested... cut-n-paste this to a file on a Linux operating system, then change the permissions of the file to 555 ... i.e. chmod 555 timetest.pl
Code:
#!/usr/bin/perl
use IO::Socket::INET;
$MySocket=new IO::Socket::INET->new(PeerPort=>123, #open socket
Proto=>'udp',
PeerAddr=>'132.163.4.101');
$data = chr(227) . chr(0) . chr(0) . chr(148); #LI/VN/Mode, Stratum, Poll, Precision
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Root Delay
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Root Dispersion
$data = $data . "LOCL"; #Reference Identifier
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Reference Timestamp
$data = $data . chr(0) . chr(0) . chr(0) . chr(0);
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Originate Timestamp
$data = $data . chr(0) . chr(0) . chr(0) . chr(0);
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Receive Timestamp
$data = $data . chr(0) . chr(0) . chr(0) . chr(0);
$data = $data . chr(0) . chr(0) . chr(0) . chr(0); #Transmit Timestamp
$data = $data . chr(0) . chr(0) . chr(0) . chr(0);
$MySocket->send($data); #Waiting to receive data
$MySocket->recv($data,56);
$MySocket->close(); #received data close socket
@Chars = split("", $data);
$n1 = ord($Chars[40]); #Upper 32 bits of Transmit Timestamp
$n2 = ord($Chars[41]);
$n3 = ord($Chars[42]);
$n4 = ord($Chars[43]);
$Seconds = $n4 + $n3*256 + $n2*65536 + $n1*16777216; #Seconds since Jan1, 1900
$Zone = -6; #GMT - 6 time zone adjust
#$Zone = -5; #use GMT - 5 during daylight savings
$Seconds = $Seconds + 3600*$Zone;
print "Seconds since Jan1, 1900 : $Seconds \n\r";
$Days = int((($Seconds >> 7)/675)+1); #Days since Jan1, 1900 {divide seconds by 86,400 and add 1}
print " Days since Jan1, 1900 : $Days \n\r";
$DW = ($Days-1) % 7; #Day of Week
$Years = int($Days / 365); #Years since 1900
print " Years since Jan1, 1900 : $Years \n\r";
$Days = $Days % 365; #Days this year
$LeapYears = int(($Years-1) / 4); #Leap Years since 1900
$CurrentYear = $Years + 1900 ; #Current Year
$Days = $Days - $LeapYears; #Leap Year Days Correction
print " Days this year : $Days \n\r";
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$count = 1; #Routine to determine
do { # - The Current Month
$Month = 30; # - The Current Date
$c1 = ($count & 1); #
$c2 = (($count & 8) >>3); # from the number of Days
if ($c1 != $c2) { # passed in the current year
$Month = $Month +1;
}
if ($count == 2) {
$Month = 28;
}
print "Month : $count Days in Month : $Month \n\r";
if ($Days >= $Month) {
$Days = $Days - $Month;
if ($Days <= $Month) {
$CurrentMonth = $count + 1;
$CurrentDate = $Days;
$count = 12;
}
}
$count++;
} until ($count == 13);
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$Seconds = $Seconds - ((($Years * 365)*675) *128); #Seconds this year
$SS = $Seconds;
print "\n\r";
print "$SS";
$MM = int($SS / 60);
$SS = $SS - ($MM*60); #Current Seconds
$HH = int($MM / 60);
$MM = $MM - ($HH*60); #Current Minutes
$DD = int($HH / 24);
$HH = $HH - ($DD*24); #Current Hour
print "\n\r";
print " Date: $CurrentMonth / $CurrentDate / $CurrentYear \n\r";
print " Time: $HH : $MM : $SS \n\r";
Bookmarks