Hello everybody!
Can anyone tell me how can I convert a value which I know to be CFAbsoluteTime from MacOS into DateTime value in C#?
Hello everybody!
Can anyone tell me how can I convert a value which I know to be CFAbsoluteTime from MacOS into DateTime value in C#?
It turned out, that I can convert it using following code:
TimeSpan span = TimeSpan.FromSeconds(CFAbsoluteTimeFloatValue);
var cshartpDateTime = new DateTime(2001, 1, 1).Add(span);
A CFAbsoluteTime is a double, the number of seconds since January 1st, 2001, 12am. Thus:
public static DateTime CFAbsoluteTimeToDateTime(double abs) {
long ticks = (long)(abs * 1E7); // 1 tick == 100 nsec
return new DateTime(new DateTime(2001, 1, 1).Ticks + ticks);
}