Skip to content

Commit

Permalink
v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
pkotets committed Feb 22, 2024
1 parent 7eb8071 commit 2d78561
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### [1.5.1] 2024-02-22

**BUGFIX:**

- `Utils::receiptJsonSerialize()`: DateTime field serialization fixed fix, handle possible exception in case of wrong format

### [1.5.0] 2023-08-31

**IMPROVEMENTS:**
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"php"
],
"homepage": "https://github.com/readdle/app-store-receipt-verification",
"version": "1.5.0",
"version": "1.5.1",
"autoload": {
"psr-4": {
"Readdle\\AppStoreReceiptVerification\\": "src/"
Expand Down
8 changes: 7 additions & 1 deletion src/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use DateTime;
use DateTimeZone;
use Exception;
use Readdle\AppStoreReceiptVerification\PKCS7\AppStore\AbstractField;

use function base64_encode;
Expand Down Expand Up @@ -53,7 +54,12 @@ public static function receiptJsonSerialize(array $fields, bool $includeUnknown
continue;
}

$dt = DateTime::createFromFormat('Y-m-d\TH:i:s\Z', $value);
try {
$dt = new DateTime($value);
} catch (Exception $e) {
continue;
}

$receipt[$type . '_ms'] = (string) ($dt->getTimestamp() * 1000);

$dt->setTimezone(new DateTimeZone('Etc/GMT'));
Expand Down

0 comments on commit 2d78561

Please sign in to comment.