public static bool IsTimeZoneEqual(double metadataLocationLatitude, double metadataLocationLongitude, DateTime dateTimeMediaTaken, DateTime dateTimeLocation, out string TimeZoneVerfification) { DateTime dateTimeMediaTakenWithoutZone = new DateTime(dateTimeMediaTaken.Ticks); DateTime dateTimeLocationUTC = new DateTime(dateTimeLocation.ToUniversalTime().Ticks, DateTimeKind.Utc); TimeZoneInfo timeZoneInfoGPSLocation = TimeZoneLibrary.GetTimeZoneInfoOnGeoLocation(metadataLocationLatitude, metadataLocationLongitude); if (timeZoneInfoGPSLocation != null) { TimeSpan timeSpanForDate = timeZoneInfoGPSLocation.GetUtcOffset(dateTimeLocation); TimeZoneVerfification = "Media Digitized: " + dateTimeMediaTakenWithoutZone.ToString() + "\r\n" + "GPS UTC date/time: " + dateTimeLocationUTC.ToString() + "\r\n" + "Time zone name (Lat,Long): " + timeZoneInfoGPSLocation.DisplayName + "\r\n" + "Base UTC offset (Lat,Long): " + timeZoneInfoGPSLocation.BaseUtcOffset.ToString() + "\r\n" + "Daylight/Standard time (GPS clock):" + (timeZoneInfoGPSLocation.IsDaylightSavingTime(dateTimeLocationUTC) ? timeZoneInfoGPSLocation.DaylightName : timeZoneInfoGPSLocation.StandardName) + "\r\n" + "Offset UTC offset (GPS clock): " + timeZoneInfoGPSLocation.GetUtcOffset(dateTimeLocationUTC).ToString() + "\r\n" + "Time Span between GPS and Digitized: " + timeSpanForDate.ToString(); return(IsTimeSpanEqual(timeSpanForDate, timeZoneInfoGPSLocation.GetUtcOffset(dateTimeLocationUTC), 15)); } else { TimeZoneVerfification = "Media Digitized: " + dateTimeMediaTakenWithoutZone.ToString() + "\r\n" + "GPS UTC date/time: " + dateTimeLocationUTC.ToString() + "\r\n" + "Time zone name (Lat,Long): GPS location incorrect\r\n" + "Base UTC offset (Lat,Long): GPS location incorrect\r\n" + "Daylight/Standard time (GPS clock): GPS location incorrect\r\n" + "Offset UTC offset (GPS clock): GPS location incorrect\r\n" + "Time Span between GPS and Digitized: Unknown: GPS Location unknown"; return(false); } }
public static TimeSpan?CalulateTimeDiffrentWithoutTimeZone(string dataTimeString1, string dateTimeString2) { DateTime?dateTime1 = TimeZoneLibrary.ParseDateTimeAsUTC(dataTimeString1); DateTime?dateTime2 = TimeZoneLibrary.ParseDateTimeAsUTC(dateTimeString2); return(CalulateTimeDiffrentWithoutTimeZone(dateTime1, dateTime2)); }