I have a Windows FILETIME :
A 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 (UTC))
and I need it rounded UP to the nearest even second, as described here.
The code I have so far:
var originalDt = DateTime.FromFileTimeUtc(input);
// round it UP to the nearest Second
var newDt = originalDt.AddMilliseconds(1000 - originalDt.Millisecond);
// then if our new Second isn't even
if (newDt.Second % 2 != 0)
{
// add one second to it, then it'll be even
newDt = newDt.AddSeconds(1);
}
return newDt.ToFileTimeUtc();
doesn't quite work... it turns 130790247821478763 into 130790247820008763, I'm after 130790247800000000.
Maths isn't my strongest subject... can I just zero those last four digits safely? Or should I forget the above code and just zero the last eight digits completely? Or... another way?