Remove deprecated mac API from dng_date_time.cpp am: 50f6082727 am: bf24c2ce51

Change-Id: I4f76dd8cc195a1763630617835b8e8b4c691f9d2
diff --git a/source/dng_date_time.cpp b/source/dng_date_time.cpp
index bede131..b143181 100644
--- a/source/dng_date_time.cpp
+++ b/source/dng_date_time.cpp
@@ -806,32 +806,44 @@
 		#if qMacOS
 		
 		CFTimeZoneRef zoneRef = CFTimeZoneCopyDefault ();
-		
+
+		CFReleaseHelper<CFTimeZoneRef> zoneRefDeleter (zoneRef);
+
 		if (zoneRef)
 			{
-			
-			CFGregorianDate gregDate;
 
-			gregDate.year   = dt.fYear;
-			gregDate.month  = (SInt8) dt.fMonth;
-			gregDate.day    = (SInt8) dt.fDay;
-			gregDate.hour   = (SInt8) dt.fHour;
-			gregDate.minute = (SInt8) dt.fMinute;
-			gregDate.second = (SInt8) dt.fSecond;
-			
-			CFAbsoluteTime absTime = CFGregorianDateGetAbsoluteTime (gregDate, zoneRef);
-			
-			CFTimeInterval secondsDelta = CFTimeZoneGetSecondsFromGMT (zoneRef, absTime);
-		
-			CFRelease (zoneRef);
-			
-			result.SetOffsetSeconds (Round_int32 (secondsDelta));
-			
-			if (result.IsValid ())
+			// New path that doesn't use deprecated CFGregorian-based APIs.
+
+			CFCalendarRef calendar =
+				CFCalendarCreateWithIdentifier (kCFAllocatorDefault,
+												kCFGregorianCalendar);
+
+			CFReleaseHelper<CFCalendarRef> calendarDeleter (calendar);
+
+			CFAbsoluteTime absTime;
+
+			if (CFCalendarComposeAbsoluteTime (calendar,
+											   &absTime,
+											   "yMdHms",
+											   dt.fYear,
+											   dt.fMonth,
+											   dt.fDay,
+											   dt.fHour,
+											   dt.fMinute,
+											   dt.fSecond))
 				{
-				return result;
+
+				CFTimeInterval secondsDelta = CFTimeZoneGetSecondsFromGMT (zoneRef, absTime);
+
+				result.SetOffsetSeconds (Round_int32 (secondsDelta));
+
+				if (result.IsValid ())
+					{
+					return result;
+					}
+
 				}
-			
+
 			}
 		
 		#endif
diff --git a/source/dng_utils.h b/source/dng_utils.h
index 691f0b9..db38599 100644
--- a/source/dng_utils.h
+++ b/source/dng_utils.h
@@ -1259,6 +1259,46 @@
 
 /*****************************************************************************/
 
+#if qMacOS
+
+/*****************************************************************************/
+
+template<typename T>
+class CFReleaseHelper
+	{
+
+	private:
+
+		T fRef;
+
+	public:
+
+		CFReleaseHelper (T ref)
+			:	fRef (ref)
+			{
+			}
+
+		~CFReleaseHelper ()
+			{
+			if (fRef)
+				{
+				CFRelease (fRef);
+				}
+			}
+
+		T Get () const
+			{
+			return fRef;
+			}
+
+	};
+
+/*****************************************************************************/
+
+#endif	// qMacOS
+
+/*****************************************************************************/
+
 #endif
 	
 /*****************************************************************************/