summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-27 07:59:17 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-02-27 07:59:17 +0000
commitc4d236f0cce3871c88356debc2faa769f7ac36bf (patch)
treece22f5e0e217c88386c4ea958aeb3a4aead55d6a
parent021f4f74994635d7739d637f206aca1949eadc0a (diff)
parentbf3719a1e2a4ed78f89c5f22389beed2ad9589d9 (diff)
downloaddng_sdk-c4d236f0cce3871c88356debc2faa769f7ac36bf.tar.gz
Remove deprecated mac API from dng_date_time.cpp am: 50f6082727 am: bf24c2ce51 am: fd1be0332e am: bc414c54e0 am: bf3719a1e2
Change-Id: I04b05128bd2bb45710be53bd0ee4e2e890a975d8
-rw-r--r--source/dng_date_time.cpp54
-rw-r--r--source/dng_utils.h40
2 files changed, 73 insertions, 21 deletions
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 @@ dng_time_zone LocalTimeZone (const dng_date_time &dt)
#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 @@ void LimitFloatBitDepth (dng_host &host,
/*****************************************************************************/
+#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
/*****************************************************************************/