/usr/share/php/Horde/Date/Parser/Locale/Base/Scalar.php is in php-horde-date-parser 2.0.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | <?php
class Horde_Date_Parser_Locale_Base_Scalar
{
public $scalarRegex = '/^\d*$/';
public $dayRegex = '/^\d\d?$/';
public $monthRegex = '/^\d\d?$/';
public $yearRegex = '/^([1-9]\d)?\d\d?$/';
public $timeSignifiers = array('am', 'pm', 'morning', 'afternoon', 'evening', 'night');
public function scan($tokens)
{
foreach ($tokens as $i => &$token) {
$postToken = isset($tokens[$i + 1]) ? $tokens[$i + 1]->word : null;
if (!is_null($t = $this->scanForScalars($token, $postToken))) {
$token->tag('scalar', $t);
}
if (!is_null($t = $this->scanForDays($token, $postToken))) {
$token->tag('scalar_day', $t);
}
if (!is_null($t = $this->scanForMonths($token, $postToken))) {
$token->tag('scalar_month', $t);
}
if (!is_null($t = $this->scanForYears($token, $postToken))) {
$token->tag('scalar_year', $t);
}
}
return $tokens;
}
public function scanForScalars($token, $postToken)
{
if (preg_match($this->scalarRegex, $token->word)) {
if (!in_array($postToken, $this->timeSignifiers)) {
return $token->word;
}
}
}
public function scanForDays($token, $postToken)
{
if (preg_match($this->dayRegex, $token->word)) {
if ($token->word <= 31 && !in_array($postToken, $this->timeSignifiers)) {
return $token->word;
}
}
}
public function scanForMonths($token, $postToken)
{
if (preg_match($this->monthRegex, $token->word)) {
if ($token->word <= 12 && !in_array($postToken, $this->timeSignifiers)) {
return $token->word;
}
}
}
public function scanForYears($token, $postToken)
{
if (preg_match($this->yearRegex, $token->word)) {
if (!in_array($postToken, $this->timeSignifiers)) {
return $token->word;
}
}
}
}
|