Skip to content

Commit 127cd52

Browse files
authored
Fix plist date parsing (#476)
1 parent fabe8d8 commit 127cd52

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/launchpad/size/analyzers/apple.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,20 @@ def analyze(self, artifact: AppleArtifact) -> AppleAnalysisResults:
259259

260260
return results
261261

262+
def parse_plist_date(self, date_value: str | datetime | None) -> str | None:
263+
if date_value is None:
264+
return None
265+
266+
if isinstance(date_value, str):
267+
try:
268+
dt = datetime.fromisoformat(date_value)
269+
return dt.isoformat()
270+
except (ValueError, AttributeError):
271+
logger.debug(f"Could not parse date string: {date_value}")
272+
return date_value
273+
274+
return date_value.isoformat()
275+
262276
@sentry_sdk.trace
263277
def _extract_app_info(self, xcarchive: ZippedXCArchive) -> AppleAppInfo:
264278
"""Extract basic app information.
@@ -278,16 +292,12 @@ def _extract_app_info(self, xcarchive: ZippedXCArchive) -> AppleAppInfo:
278292
if provisioning_profile:
279293
codesigning_type, profile_name = self._get_profile_type(provisioning_profile)
280294
expiration_date = provisioning_profile.get("ExpirationDate")
281-
if expiration_date:
282-
# Convert datetime to ISO format string
283-
profile_expiration_date = expiration_date.isoformat()
295+
profile_expiration_date = self.parse_plist_date(expiration_date)
284296
certificate_expiration_date = self._extract_certificate_expiration_date(provisioning_profile)
285297

286-
build_date = None
287298
archive_plist = xcarchive.get_archive_plist()
288299
if archive_plist:
289-
creation_date = archive_plist.get("CreationDate")
290-
build_date = creation_date.isoformat() if creation_date else None
300+
build_date = self.parse_plist_date(archive_plist.get("CreationDate"))
291301

292302
supported_platforms = plist.get("CFBundleSupportedPlatforms", [])
293303
is_simulator = "iphonesimulator" in supported_platforms or plist.get("DTPlatformName") == "iphonesimulator"

0 commit comments

Comments
 (0)