I am new to objective-C and Mac:
How to convert the Windows64BitSeconds in below to its MacOS NSDate localtime and UTC?. By some online reading/searching came up with the following, but not sure if this is correct.
//found some useful code online: Convert Windows Filetime to second in Unix/Linux
#define WINDOWS_TICK 10000000
#define SEC_TO_UNIX_EPOCH 11644473600LL
windows-filetime-to-second-in-unix-linux.
unsigned WindowsTickToUnixSeconds(long long windowsTicks)
{
return (unsigned)(windowsTicks / WINDOWS_TICK - SEC_TO_UNIX_EPOCH);
}
long long Windows64BitSeconds = A 64 Bit Value of type FILETIME;
long long UnixSeconds = WindowsTickToUnixSeconds(Windows64BitSeconds);
NSDate *srcDate = [NSDate dateWithTimeIntervalSince1970:UnixSeconds];
NSLog(@"srcDate=%@", srcDate); //What this supposed to display, UTC?.This seems to display local time???
NSTimeZone* localTZ = [NSTimeZone localTimeZone];
NSTimeZone* utcTZ = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
NSInteger localGMTOffset = [localTZ secondsFromGMTForDate:sourceDate];
NSInteger gmtOffset = [utcTZ secondsFromGMTForDate:sourceDate];
NSTimeInterval gmtInterval = gmtOffset - localGMTOffset;
NSDate* destDate = [[NSDate alloc] initWithTimeInterval:gmtInterval sinceDate:srcDate];
NSLog(@"destinationDate=%@", destDate); //What this supposed to display, UTC?.This seems to display Localtime???
Not certain abut the above code versus the correct code?.