1: <?php
2: 3:
4: class Horde_Date_Parser_Locale_De extends Horde_Date_Parser_Locale_Base
5: {
6: 7: 8: 9: 10: 11:
12: public function preNormalize($text)
13: {
14: $text = strtolower($text);
15: $text = $this->numericizeNumbers($text);
16: $text = preg_replace('/[\'"\.]/', '', $text);
17: $text = preg_replace('/([\/\-\,\@])/', ' \1 ', $text);
18: $text = preg_replace('/\bheute\b/', 'dieser tag', $text);
19: $text = preg_replace('/\bmorgen\b/', 'nächster tag', $text);
20: $text = preg_replace('/\bgestern\b/', 'letzter tag', $text);
21: $text = preg_replace('/\bmittags?\b/', '12:00', $text);
22: $text = preg_replace('/\bmitternachts?\b/', '24:00', $text);
23: $text = preg_replace('/\bjetzt\b/', 'diese sekunde', $text);
24: $text = preg_replace('/\b(vor|früher)\b/', 'past', $text);
25: $text = preg_replace('/\b(?:in|during) the (morning)\b/', '\1', $text);
26: $text = preg_replace('/\bam (morgen|nachmittag|abend)\b/', '\1', $text);
27: $text = preg_replace('/\in der nacht\b/', 'nachts', $text);
28: $text = $this->numericizeOrdinals($text);
29:
30: return $text;
31: }
32:
33: 34: 35: 36: 37: 38: 39: 40:
41: public function postTokenize($tokens)
42: {
43: $tokens = parent::postTokenize($tokens);
44:
45: foreach ($tokens as $num => $token) {
46: if ($num >= 2 &&
47: ($repeater = $token->getTag('repeater')) &&
48: $repeater instanceof Horde_Date_Repeater_Day &&
49: ($grabber = $tokens[$num - 1]->getTag('grabber')) &&
50: $grabber == 'next') {
51: $token = new Horde_Date_Parser_Token('');
52: $token->tag('repeater_day_portion',
53: new Horde_Date_Repeater_DayPortion('morning'));
54: array_splice(
55: $tokens,
56: $num - 1,
57: 2,
58: array($token));
59: return $tokens;
60: }
61: }
62: return $tokens;
63: }
64: }
65: