PluginProbe
Media Cloud Sync / 1.4.2
Media Cloud Sync v1.4.2
1.4.2 1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 All 36 releases
← All changes | includes/sdk/s3/Aws/Api/DateTimeResult.php +6 -0 1.2.3 → 1.4.2 View file →
@@ -11,8 +11,9 @@
11 11 * with JSON documents, and with JMESPath.
12 12 */
13 13 class DateTimeResult extends \DateTime implements \JsonSerializable
14 14 {
15 + private const ISO8601_NANOSECOND_REGEX = '/^(.*\\.\\d{6})(\\d{1,3})(Z|[+-]\\d{2}:\\d{2})?$/';
15 16 /**
16 17 * Create a new DateTimeResult from a unix timestamp.
17 18 * The Unix epoch (or Unix time or POSIX time or Unix
18 19 * timestamp) is the number of seconds that have elapsed since
@@ -44,8 +45,13 @@
44 45 public static function fromISO8601($iso8601Timestamp)
45 46 {
46 47 if (\is_numeric($iso8601Timestamp) || !\is_string($iso8601Timestamp)) {
47 48 throw new ParserException('Invalid timestamp value passed to DateTimeResult::fromISO8601');
49 + }
50 + // Prior to 8.0.10, nanosecond precision is not supported
51 + // Reduces to microsecond precision if nanosecond precision is detected
52 + if (\PHP_VERSION_ID < 80010 && \preg_match(self::ISO8601_NANOSECOND_REGEX, $iso8601Timestamp, $matches)) {
53 + $iso8601Timestamp = $matches[1] . ($matches[3] ?? '');
48 54 }
49 55 return new DateTimeResult($iso8601Timestamp);
50 56 }
51 57 /**