Skip to content

Commit 3378a52

Browse files
committed
Further improve regex and unit tests
1 parent 416e92a commit 3378a52

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/XMLSchema/Type/DateTimeValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class DateTimeValue extends AbstractAnySimpleType
3131
protected function sanitizeValue(string $value): string
3232
{
3333
$normalized = static::collapseWhitespace(static::normalizeWhitespace($value));
34-
$sanitized = preg_replace('/\.(\d{0,6})\d*/', '.$1', $normalized);
34+
$sanitized = preg_replace('/\.(\d{0,12})\d*/', '.$1', $normalized);
3535

3636
// Remove all trailing zeros after the dot, and remove the dot if only zeros were present
3737
$sanitized = preg_replace('/\.(?=\d)(?:\d*?[1-9])?\K0+(?=[^0-9]|$)/', '', $sanitized);

src/XMLSchema/Type/TimeValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TimeValue extends AbstractAnySimpleType
3131
protected function sanitizeValue(string $value): string
3232
{
3333
$normalized = static::collapseWhitespace(static::normalizeWhitespace($value));
34-
$sanitized = preg_replace('/\.(\d{0,6})\d*/', '.$1', $normalized);
34+
$sanitized = preg_replace('/\.(\d{0,12})\d*/', '.$1', $normalized);
3535

3636
// Remove all trailing zeros after the dot, and remove the dot if only zeros were present
3737
$sanitized = preg_replace('/\.(?=\d)(?:\d*?[1-9])?\K0+(?=[^0-9]|$)/', '', $sanitized);

0 commit comments

Comments
 (0)