forked from ruflin/Elastica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DateProcessor.php
57 lines (50 loc) · 1.35 KB
/
DateProcessor.php
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
<?php
namespace Elastica\Processor;
/**
* Elastica Date Processor.
*
* @author Federico Panini <[email protected]>
*
* @see https://www.elastic.co/guide/en/elasticsearch/reference/current/date-processor.html
*/
class DateProcessor extends AbstractProcessor
{
use Traits\FieldTrait;
use Traits\IgnoreFailureTrait;
use Traits\TargetFieldTrait;
public const DEFAULT_TARGET_FIELD_VALUE = '@timestamp';
public const DEFAULT_TIMEZONE_VALUE = 'UTC';
public const DEFAULT_LOCALE_VALUE = 'ENGLISH';
public function __construct(string $field, array $formats)
{
$this->setField($field);
$this->setFormats($formats);
}
/**
* Set field format. Joda pattern or one of the following formats ISO8601, UNIX, UNIX_MS, or TAI64N.
*
* @return $this
*/
public function setFormats(array $formats): self
{
return $this->setParam('formats', $formats);
}
/**
* Set the timezone use when parsing the date. Default UTC.
*
* @return $this
*/
public function setTimezone(string $timezone): self
{
return $this->setParam('timezone', $timezone);
}
/**
* Set the locale to use when parsing the date.
*
* @return $this
*/
public function setLocale(string $locale): self
{
return $this->setParam('locale', $locale);
}
}