[mrtg] Epoch Time problems with PERL built for MSWin32

Payn, Drew drew.payn at au.unisys.com
Wed Jul 21 08:47:19 MEST 1999


      Anyone else experiencing the same problems?  It seems to me Win32 Perl
Epoch time function is not working correctly and thus data logged is
incorrect. Am I making a mistake here somewhere?

> A little abnormality with Perl on Win32 (I.e. WinNT4.0p5) I hope you can
> explain
> 
> Current version is Perl v5.00503 running on 6x86 built for MSWin32
> 
	When I run a script such as:


> 	# start at 1/1/99 0:0
> 	my ($prmin) = 922539600;
> 
>   	while ($primin < 922550400) {
> 		($sec, $min, $hour, $mday, $mon, $year, $wday, $yday,
> $isdst) = localtime($prmin);	
> 	 	$mon++; 
> 	      printf("%d,%d%02d%02d %02d:%02d:%02d\n", $prmin, $year, $mon,
> $mday, $hour, $min, $sec);
> 		$prmin = $prmin + 100;
>   	} 
> 
> 
> 	Note: This script does not stop at 922550400, I did not get to fix
> this problem as I did not think it important at this time. 
> 
> 	A section of output was:
> 
> 922546300,990328 01:51:40
> 922546400,990328 01:53:20
> 922546500,990328 01:55:00
> 922546600,990328 01:56:40
> 922546700,990328 01:58:20
> 922546800,990328 01:00:00
> 922546900,990328 01:01:40
> 922547000,990328 01:03:20
> 922547100,990328 01:05:00
> 
> 	We see that it does not tick over correctly.  It seems to faulter
> and skip back an hour at 922546800.  
> 
> 	Looks like it is a related to this release.  Exactly the same script
> on Unix:
> 
> > prlver.prl
> Current version is 5.00501 running on  built for solaris    
> 
> 922546200,990327 14:50:00
> 922546300,990327 14:51:40
> 922546400,990327 14:53:20
> 922546500,990327 14:55:00
> 922546600,990327 14:56:40
> 922546700,990327 14:58:20
> 922546800,990327 15:00:00
> 922546900,990327 15:01:40
> 922547000,990327 15:03:20    
> 
> 	So it gives different dates and times for exactly the same epoch
> number.
> 
> 	On an earlier Win32 version of Perl (different h/w as well)
> 
> C:\PERL\test>perl prlver.pl
> Current version is 5.00307 running on 5x86 built for MSWin32
> 
> 
> 922543200,990328 00:00:00
> 922543300,990328 00:01:40
> 922543400,990328 00:03:20
> 922543500,990328 00:05:00
> ....
> 922546700,990328 00:58:20
> 922546800,990328 01:00:00
> 922546900,990328 01:01:40
> 922547000,990328 01:03:20
> 
> 
> 	Different date and times on all three systems/versions?  What gives?
> 
> 
> 	I discovered this by trying to port output from a Perl script into
> Microsoft Excel spreadsheet and using the "recommended" formula for
> conversion of epoch time to 1900 based systems (as is Excel) of
> "=(x+((365*70+17)*86400))/86400", found this did not work as a value of
> "x=0"  gave an Excel date of  "12/30/69 0:00" and not "1/1/70 0:00" as
> expected.  
> 
> 	I then changed the formula to "=(x+((365*70+19)*86400))/86400",  to
> fix this problem, I dont know why, there has only been 17 leap years from
> 1900 thru 1970, correct?
> 
> 	However even after this modification the current epoch time produced
> from Perl "time" function did not match what Excel interpreted it too
> 
> Perl						Excel[using formula]
> 932432442 = 990720 11:00:42		7/20/99 1:00
> [=(932432442+(365*70+19)*86400)/86400]
> 
> 	there is a 10 hour difference here.
> 
		The Unix data converts to Excel date correctly, neither of
the Win32 data does.

> 	Rgds
> 	Drew
> 

--
* To unsubscribe from the mrtg mailing list, send a message with the
  subject: unsubscribe to mrtg-request at list.ee.ethz.ch
* The mailing list archive is at http://www.ee.ethz.ch/~slist/mrtg


More information about the mrtg mailing list