Familien Schøler’s blog

Lidt af hvert fra hverdagen hos Michael, Kamilla, Marie og Katrine Schøler

Strømsvigt og intet varmt vand i hanerne i Egå

Egå/omegn

Vi vågnede op til opdagelsen af at der (igen) har været strømsvigt i nattens løb i Egå/omegn. Det sker lidt for tit synes jeg. Vi har været udsat for mindst 10 strømafbrydelser (hele Egå og fra eget HFI-relæ), i den tid vi har boet i Egå. Server og backup harddiske var naturligvis blevet afbrudt hvilket absolut ikke er godt for udstyret:

#  Time                 Class     Severity   Message
1  2008-04-20 06:58:49  storage   notice     Detected Disk1 I/O Error

Det varme vand må vi endvidere kigge langt efter her til morgen. Det skulle være sundt med et iskoldt brusebad, men jeg har valgt at sætte helbredet på spil til senere på dagen hvor der forhåbentligt atter er mulighed for ikke at skulle sprinkle sig selv med isterninger.

*grumpf*

C# API documentation issues

According to http://msdn2.microsoft.com/en-us/library/system.datetime_methods(VS.71).aspx the AddHours() method for any DateTime instance has the following effect:

AddHours: Adds the specified number of hours to the value of this instance.

This means that given a DateTime object “dt”, and that the method AddHours is called on that object, the specific object instance “dt” will be updated with the new value.

DateTime codecompletion hint

As can be seen above, this is also what is shown in the codecompletion hint text in Microsoft Visual Studio 2005.

So the following code should yield the new date value “2008-04-17 10:03:00″:

DateTime dt = new DateTime(2008, 04, 17);
// The object instance "dt" is now equal to "2008-04-17 00:00:00
dt.AddHours(10.0);
dt.AddMinutes(3.0);
// "dt" is now "2008-04-17 00.00.00" ?!

… but instead it yields the value “2008-04-17 00:00:00″.

Digging further in the API documentation you’ll find a contradiction on the method description pages, eg. http://msdn2.microsoft.com/en-us/library/system.datetime.addhours(VS.71).aspx:

Return Value
A DateTime whose value is the sum of the date and time represented by this instance and the number of hours represented by value.

This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.

So the correct code is:

DateTime dt = new DateTime(2008, 04, 17);
// The object instance "dt" is now equal to "2008-04-17 00:00:00
dt = dt.AddHours(10.0);
dt = dt.AddMinutes(3.0);
// "dt" is now "2008-04-17 10.03.00"

And that’s not playing nice – now is it? The definition text is ambiguous. Looking closely to the hint text you’ll notice that a DateTime object instance is returned when calling the AddHours method: “DateTime DateTime.AddHours(double value)”.

I suggest correcting the documentation text to the following unambiguous definition:

AddHours: Returns a new DateTime with the specified number of hours added to the value of this instance.