我需要将NSDate转换为C#ticks.
DateTime.ticks将日期转换为从0001年1月1日开始的刻度.
我怎样才能做到这一点?
提前致谢.
我在某个地方借了这个代码,所以我不是作者.它来了:
原文链接:https://www.f2er.com/swift/320098.html@implementation NSDate (Ticks) - (long long) ticks { double tickFactor = 10000000; long long tickValue = (long long)floor([self timeIntervalSince1970] * tickFactor) + 621355968000000000LL; return tickValue; } + (NSDate*) dateWithTicks:(long long)ticks { double tickFactor = 10000000; double seconds = (ticks - 621355968000000000LL) / tickFactor; return [NSDate dateWithTimeIntervalSince1970:seconds]; } @end