diff --git a/example/example.xml b/example/example.xml index d49921f..6dc8908 100755 --- a/example/example.xml +++ b/example/example.xml @@ -89,7 +89,9 @@ - + + + diff --git a/src/Preparation/Processor/Property/Assert/TimeZoneStrategy.php b/src/Preparation/Processor/Property/Assert/TimeZoneStrategy.php index 4c7e321..0e70636 100644 --- a/src/Preparation/Processor/Property/Assert/TimeZoneStrategy.php +++ b/src/Preparation/Processor/Property/Assert/TimeZoneStrategy.php @@ -23,11 +23,45 @@ protected function generateArguments(array $config): array $parent['countryCode'] = $config['country_code'] ?? null; $parent['intlCompatible'] = $this->stringToBool($config['intl_compatible'] ?? 'false'); - $parent['zone'] = (int) ($config['zone'] ?? \DateTimeZone::ALL); + + $this->applyTz($parent, $config); return array_filter($parent); } + /** + * @param array $args + * @param array $config + * + * @return void + */ + protected function applyTz(array &$args, array $config): void + { + $zone = 0; + if (empty($config['zone'])) { + $args['zone'] = \DateTimeZone::ALL; + + return; + } + + $zones = $config['zone']; + foreach ($zones as $z) { + $zone |= $this->getTzValue($z['value']); + } + + $args['zone'] = $zone; + } + + protected function getTzValue(string $zoneName): int + { + $constName = sprintf('%s::%s', \DateTimeZone::class, $zoneName); + if (!\defined($constName)) { + throw new \InvalidArgumentException(sprintf('Time zone `%s` is not defined in class %s', $zoneName, \DateTimeZone::class)); + } + + return \constant($constName); + } + protected function getValidatorProperty(): string { return 'time_zone'; diff --git a/src/Resource/schema/dto-1.6.xsd b/src/Resource/schema/dto-1.6.xsd index a493195..89af122 100755 --- a/src/Resource/schema/dto-1.6.xsd +++ b/src/Resource/schema/dto-1.6.xsd @@ -135,31 +135,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + + @@ -363,4 +342,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Unit/example.xml b/tests/Unit/example.xml index 6f7b17a..c803f0c 100755 --- a/tests/Unit/example.xml +++ b/tests/Unit/example.xml @@ -94,7 +94,9 @@ - + + +