Skip to content

Commit

Permalink
fixes #9365 - fix date range format handling for languages with strin…
Browse files Browse the repository at this point in the history
…g literals (e.g. spanish)
  • Loading branch information
sgiehl committed Dec 9, 2015
1 parent db36ca3 commit e788cdf
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion core/Period.php
Expand Up @@ -349,10 +349,12 @@ protected function explodeFormat($format)
);

$offset = strlen($format);
// replace string literals encapsulated by ' with same country of *
$cleanedFormat = preg_replace_callback('/(\'[^\']+\')/', array($this, 'replaceWithStars'), $format);

// search for first duplicate date field
foreach ($intervalTokens AS $tokens) {
if (preg_match_all('/[' . implode('|', $tokens) . ']+/', $format, $matches, PREG_OFFSET_CAPTURE) &&
if (preg_match_all('/[' . implode('|', $tokens) . ']+/', $cleanedFormat, $matches, PREG_OFFSET_CAPTURE) &&
count($matches[0]) > 1 && $offset > $matches[0][1][1]
) {
$offset = $matches[0][1][1];
Expand All @@ -362,6 +364,11 @@ protected function explodeFormat($format)
return array(substr($format, 0, $offset), substr($format, $offset));
}

private function replaceWithStars($matches)
{
return str_repeat("*", strlen($matches[0]));
}

protected function getRangeFormat($short = false)
{
$maxDifference = 'D';
Expand Down

0 comments on commit e788cdf

Please sign in to comment.