S
sumip
I just made a pretty strange observation with .NET 2.0 -
DateTime.AddMilliseconds(double) and AddSeconds(double) seem to be
broken:
DateTime now = new DateTime();
DateTime t2 = now.AddMilliseconds(1.5);
Console.Out.WriteLine(t2.TimeOfDay);
The code above rounds the fraction to full milliseconds and results in
this output:
00:00:00.0020000
However, if I use AddTicks, the result is as expected:
DateTime now = new DateTime();
DateTime t2 = now.AddTicks(15000);
Console.Out.WriteLine(t2.TimeOfDay);
Output: 00:00:00.0015000
IMHO, AddMillisecond should work completely different. From the
documentation of AddMilliseconds:
<quote>
The fractional part of value is the fractional part of a millisecond.
For example, 4.5 is equivalent to 4 milliseconds, and 5000 ticks, where
one millisecond = 10000 ticks.
</quote>
However, I just can't imagine that there is such a severe bug in the
framework. Any ideas?
Cheers,
Philipp
DateTime.AddMilliseconds(double) and AddSeconds(double) seem to be
broken:
DateTime now = new DateTime();
DateTime t2 = now.AddMilliseconds(1.5);
Console.Out.WriteLine(t2.TimeOfDay);
The code above rounds the fraction to full milliseconds and results in
this output:
00:00:00.0020000
However, if I use AddTicks, the result is as expected:
DateTime now = new DateTime();
DateTime t2 = now.AddTicks(15000);
Console.Out.WriteLine(t2.TimeOfDay);
Output: 00:00:00.0015000
IMHO, AddMillisecond should work completely different. From the
documentation of AddMilliseconds:
<quote>
The fractional part of value is the fractional part of a millisecond.
For example, 4.5 is equivalent to 4 milliseconds, and 5000 ticks, where
one millisecond = 10000 ticks.
</quote>
However, I just can't imagine that there is such a severe bug in the
framework. Any ideas?
Cheers,
Philipp