Skip to content

Commit d6a10bd

Browse files
committed
Voice start and end time filters must be UTC
1 parent 5b40b64 commit d6a10bd

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

src/Call/Filter.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,15 @@ public function setStatus($status)
3838

3939
public function setStart(\DateTime $start)
4040
{
41-
$this->query['date_start'] = $start->format('c');
41+
$start->setTimezone(new \DateTimeZone("UTC"));
42+
$this->query['date_start'] = $start->format('Y-m-d\TH:i:s\Z');
4243
return $this;
4344
}
4445

45-
public function setEnd(\DateTime $start)
46+
public function setEnd(\DateTime $end)
4647
{
47-
$this->query['date_end'] = $start->format('c');
48+
$end->setTimezone(new \DateTimeZone("UTC"));
49+
$this->query['date_end'] = $end->format('Y-m-d\TH:i:s\Z');
4850
return $this;
4951
}
5052

@@ -76,4 +78,4 @@ public function setConversation($conversation)
7678

7779
return $this;
7880
}
79-
}
81+
}

test/Call/FilterTest.php

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,38 @@ public function testStatus()
4848

4949
public function testStart()
5050
{
51-
$date = new \DateTime();
51+
$date = new \DateTime('2018-03-31 11:33:42');
5252
$this->filter->setStart($date);
5353
$query = $this->filter->getQuery();
5454
$this->assertArrayHasKey('date_start', $query);
55-
$this->assertEquals($date->format('c'), $query['date_start']);
55+
$this->assertEquals('2018-03-31T11:33:42Z', $query['date_start']);
56+
}
57+
58+
public function testStartOtherTimezone()
59+
{
60+
$date = new \DateTime('2018-03-31 11:33:42-03:00');
61+
$this->filter->setStart($date);
62+
$query = $this->filter->getQuery();
63+
$this->assertArrayHasKey('date_start', $query);
64+
$this->assertEquals('2018-03-31T14:33:42Z', $query['date_start']);
5665
}
5766

5867
public function testEnd()
5968
{
60-
$date = new \DateTime();
69+
$date = new \DateTime('2018-03-31 11:33:42');
70+
$this->filter->setEnd($date);
71+
$query = $this->filter->getQuery();
72+
$this->assertArrayHasKey('date_end', $query);
73+
$this->assertEquals('2018-03-31T11:33:42Z', $query['date_end']);
74+
}
75+
76+
public function testEndOtherTimezone()
77+
{
78+
$date = new \DateTime('2018-03-31 11:33:42+03:00');
6179
$this->filter->setEnd($date);
6280
$query = $this->filter->getQuery();
6381
$this->assertArrayHasKey('date_end', $query);
64-
$this->assertEquals($date->format('c'), $query['date_end']);
82+
$this->assertEquals('2018-03-31T08:33:42Z', $query['date_end']);
6583
}
6684

6785
public function testSize()

0 commit comments

Comments
 (0)