return $result->span;
case 'date':
return $result->guess();
+ // TODO: return end date (force) like all day event = 0-24
}
}
public function preNormalize($text)
{
$text = strtolower($text);
- // $text = $this->numericizeNumbers($text);
+ $text = $this->numericizeNumbers($text);
$text = preg_replace('/[\'"\.]/', '', $text);
$text = preg_replace('/([\/\-\,\@])/', ' $1 ', $text);
$text = preg_replace('/\bhoje\b/', 'this day', $text);
- // $text = preg_replace('/^amanh[aã]$/', 'next day', $text);
- $text = preg_replace('/^amanha$/', 'next day', $text);
-
- $text = preg_replace('/^ontem$/', 'last day', $text);
+ $text = preg_replace('/\bamanh[aã]\b/', 'next day', $text);
+ $text = preg_replace('/\bontem\b/', 'last day', $text);
$text = preg_replace('/\bmeio\s+dia\b/', '12:00', $text);
$text = preg_replace('/\bmeia\s+noite\b/', '24:00', $text);
$text = preg_replace('/\b(antes|anterior)\b/', 'past', $text);
$text = preg_replace('/\b(agora|j[aá])\b/', 'this second', $text);
- $text = preg_replace('/\b[uú]ltimo\b/', 'last', $text);
+ $text = preg_replace('/\b[uú]ltim[oa]\b/', 'last', $text);
$text = preg_replace('/\b(?:de|na|durante\s+a|logo(?:\s[aà]|de))\s+(manh[aã]|madrugada)\b/', 'morning', $text);
$text = preg_replace('/\b(?:de|[àa]|durante\s+a|logo(?:\s[aà]|de))\s+tarde\b/', 'afternoon', $text);
$text = preg_replace('/\b((?:de|[àa]|durante\s+a|logo(?:\s[aà]))\s+noite|(?:ao)\s+anoitecer)\b/', 'this night', $text);
- $text = preg_replace('/\b(horas?|h|hrs?)\b/', 'oclock', $text);
+ $text = preg_replace('/\b(horas?|h|hrs?)\b/', ' oclock', $text);
$text = preg_replace('/\b(depois|ap[oó]s)\b/', 'future', $text);
- $text = $this->numericizeNumbers($text);
-// $text = preg_replace('/\bdebug\b/', 'filho da mae', $text);
- return $text;
+ // $text = $this->numericizeNumbers($text);
+
+ return $text;
}
/**
* Regex tokens
*/
public $scanner = array(
- '/^(passado|[uú]ltim[ao]|anterior)$/' => 'last',
- '/^n?est[ea]$/' => 'this',
- '/^(pr[oó]xim[oa]|seguinte)$/' => 'next',
- );
+ '/(passado|[uú]ltim[ao]|anterior)/' => 'last',
+ '/n?est[ea]/' => 'this',
+ '/(pr[oó]xim[oa]|seguinte)/' => 'next',
+ '/last/' => 'last',
+ '/this/' => 'this',
+ '/next/' => 'next',
+ );
+
public function scan($tokens)
{
class Horde_Date_Parser_Locale_Pt_Ordinal extends Horde_Date_Parser_Locale_Base_Ordinal
{
- public $ordinalRegex = '/^(\d*)(\.|\xBA|\xAA|º|ª)?$/';
- public $ordinalDayRegex = '/^(0[1-9]|[12][0-9]|3[01])(\.|\xBA|\xAA|º|ª)?$/';
- public $ordinalMonthsRegex = '/^(0[1-9]|1[012])(\.|\xBA|\xAA|º|ª)?$/';
+ public $ordinalRegex = '/^(\d*)(\.|\xBA|\xAA|º|ª|st|nd|rd|th)?$/';
+ public $ordinalDayRegex = '/^(0[1-9]|[12][0-9]|3[01])(\.|\xBA|\xAA|º|ª|st|nd|rd|th)?$/';
+ public $ordinalMonthsRegex = '/^(0[1-9]|1[012])(\.|\xBA|\xAA|º|ª|st|nd|rd|th)?$/';
public function scan($tokens)
{
public $scanner = array(
'/^antes$/' => 'past',
'/^(depois(\s+de)?|ap[oó]s|dentro\s+de|daqui\s+a)$/' => 'future',
- );
+ '/\bpast\b/' => 'past',
+ '/\bfuture\b/' => 'future',
+ '/\bin\b/' => 'future',
+ );
public function scan($tokens)
{
'/^(?:de|na|a|durante\s+a) tarde$/' => 'afternoon',
'/^((fim\s(d[ea]\s)tarde)|anoitecer)$/' => 'evening',
'/^noite$/' => 'night',
- );
+ '/^ams?$/' => 'am',
+ '/^pms?$/' => 'pm',
+ '/^mornings?$/' => 'morning',
+ '/^afternoons?$/' => 'afternoon',
+ '/^evenings?$/' => 'evening',
+ '/^(night|nite)s?$/' => 'night',
+ );
public $unitScanner = array(
'/^anos?$/' => 'year',
'/^horas?$/' => 'hour',
'/^minutos?$/' => 'minute',
'/^segundos?$/' => 'second',
+ '/^years?$/' => 'year',
+ '/^seasons?$/' => 'season',
+ '/^months?$/' => 'month',
+ '/^fortnights?$/' => 'fortnight',
+ '/^weeks?$/' => 'week',
+ '/^weekends?$/' => 'weekend',
+ '/^days?$/' => 'day',
+ '/^hours?$/' => 'hour',
+ '/^minutes?$/' => 'minute',
+ '/^seconds?$/' => 'second',
);
public $timeRegex = '/^\d{1,2}(:?\d{2})?([\.:]?\d{2})?$/';
public $dayRegex = '/^(0[1-9]|[12][0-9]|3[01])?$/';
public $monthRegex = '/^(0[1-9]|1[012])$/';
public $yearRegex = '/^(19|20)?\d\d$/';
- public $timeSignifiers = array('manha', 'manhã', 'tarde', 'noite', 'madrugada', 'anoitecer');
+ // public $timeSignifiers = array('manha', 'manhã', 'tarde', 'noite', 'madrugada', 'anoitecer');
+ public $timeSignifiers = array('am', 'pm', 'morning', 'afternoon', 'evening', 'night');
public function scan($tokens)
{
public $atScanner = array(
'/^(em|@|de)$/' => 'at',
'/^(as|ao)$/' => 'at',
+ '/^(at|@)$/' => 'at',
);
public $inScanner = array(
'/^no$/' => 'in',
+ '/^in$/' => 'in',
);
public function scan($tokens)