Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 7c2f341

Browse files
committed
Merge remote-tracking branch 'Maks3w/feature/RFCi18n-ldap-dependencies'
9 parents d7310a9 + 3fd24f6 + 46b66eb + 5dc451e + 6cc63be + 36c3273 + d866e82 + 91a7d10 + 3faf4eb commit 7c2f341

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

src/Converter/Converter.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222

2323
use DateTime;
2424
use DateTimeZone;
25-
use Zend\Date\Date;
2625

2726
/**
2827
* Zend\Ldap\Converter is a collection of useful LDAP related conversion functions.
@@ -114,8 +113,6 @@ public static function toLdap($value, $type = self::STANDARD)
114113
} else if (is_object($value)) {
115114
if ($value instanceof DateTime) {
116115
return self::toLdapDatetime($value);
117-
} else if ($value instanceof Date) {
118-
return self::toLdapDatetime($value);
119116
} else {
120117
return self::toLdapSerialize($value);
121118
}
@@ -137,11 +134,10 @@ public static function toLdap($value, $type = self::STANDARD)
137134
* Converts a date-entity to an LDAP-compatible date-string
138135
*
139136
* The date-entity <var>$date</var> can be either a timestamp, a
140-
* DateTime Object, a string that is parseable by strtotime() or a Zend\Date\Date
141-
* Object.
137+
* DateTime Object, a string that is parseable by strtotime().
142138
*
143-
* @param integer|string|DateTime|Date $date The date-entity
144-
* @param boolean $asUtc Whether to return the LDAP-compatible date-string as UTC or as local value
139+
* @param integer|string|DateTime $date The date-entity
140+
* @param boolean $asUtc Whether to return the LDAP-compatible date-string as UTC or as local value
145141
* @return string
146142
* @throws Exception\InvalidArgumentException
147143
*/
@@ -153,8 +149,6 @@ public static function toLdapDateTime($date, $asUtc = true)
153149
$date->setTimezone(new DateTimeZone(date_default_timezone_get()));
154150
} else if (is_string($date)) {
155151
$date = new DateTime($date);
156-
} else if ($date instanceof Date) {
157-
$date = new DateTime($date->get(Date::ISO_8601));
158152
} else {
159153
throw new Exception\InvalidArgumentException('Parameter $date is not of the expected type');
160154
}

test/Converter/ConverterTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
use DateTime;
2525
use DateTimeZone;
26-
use Zend\Date\Date;
2726
use Zend\Ldap\Converter\Converter;
2827

2928
/**
@@ -84,11 +83,11 @@ public function toLdapDateTimeProvider()
8483
'utc' => false), '20100512131445+0300'),
8584
array(array('date'=> '2010-05-12 13:14:45+0300',
8685
'utc' => true), '20100512101445Z'),
87-
array(array('date'=> new Date('2010-05-12T13:14:45+0300', Date::ISO_8601),
86+
array(array('date'=> DateTime::createFromFormat(DateTime::ISO8601, '2010-05-12T13:14:45+0300'),
8887
'utc' => true), '20100512101445Z'),
89-
array(array('date'=> new Date('2010-05-12T13:14:45+0300', Date::ISO_8601),
88+
array(array('date'=> DateTime::createFromFormat(DateTime::ISO8601, '2010-05-12T13:14:45+0300'),
9089
'utc' => false), '20100512131445+0300'),
91-
array(array('date'=> new Date('0', Date::TIMESTAMP),
90+
array(array('date'=> date_timestamp_set(new DateTime(), 0),
9291
'utc' => true), '19700101000000Z'),
9392
);
9493
}
@@ -153,7 +152,7 @@ public function toLdapProvider()
153152
'type' => 0)),
154153
array('FALSE', array('value'=> 0,
155154
'type' => 1)),
156-
array('19700101000000Z', array('value'=> new Date('1970-01-01T00:00:00+0000', Date::ISO_8601),
155+
array('19700101000000Z', array('value'=> DateTime::createFromFormat(DateTime::ISO8601, '1970-01-01T00:00:00+0000'),
157156
'type' => 0)),
158157

159158
);
@@ -192,6 +191,11 @@ public function testFromLdapBoolean()
192191

193192
/**
194193
* @dataProvider fromLdapDateTimeProvider
194+
*
195+
* @param DateTime $expected
196+
* @param string $convert
197+
* @param boolean $utc
198+
* @return void
195199
*/
196200
public function testFromLdapDateTime($expected, $convert, $utc)
197201
{

0 commit comments

Comments
 (0)