[Mono-list] A mono bug?

Lawrence Oluyede l.oluyede@virgilio.it
Wed, 18 Feb 2004 16:16:32 +0100


I've written a simple script to compute the uptime of the machine.
It works well on MS.NET on Win2k (i tried to compare the output with 
some other similar utilities) but on Mono 0.29 on my Gentoo box it fails 
(the procps uptime tells me another time instead of the one that i get 
with my uptime). Maybe I'm wrong or maybe Mono is wrong... anyway I 
can't install Mono 0.30 cause it doesn't compile on Gentoo and on 
Windows it doesn't run :(

Here the code:

private static string getUptime()
	{
		StringBuilder buffer = new StringBuilder();
		
		int ticks = Environment.TickCount;
		
		buffer.AppendFormat(" {0:hh}:{0:mm}:{0:ss}",   DateTime.Now);
		buffer.Append(" up");
		
		// compute and append the number of days
		int days = (int) ticks / (1000 * 60 * 60 * 24);		
		if(days > 0)
		{
			buffer.AppendFormat(" {0} day{1}",
				days,
				days > 1 ? "s" : String.Empty);
		}
		
		int seconds = ticks / 1000;
		int minutes = ticks / (1000 * 60);
		int hours = minutes / 60;
		
		hours = hours % 24;
		minutes = minutes % 60;
		seconds = seconds % 60;
		
		buffer.AppendFormat(" {0,2:D2}:{1,2:D2}:{2,2:D2}", hours, minutes, 
seconds);
		
		return buffer.ToString();
	}


-- 
Lawrence