Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Sign in
Toggle navigation
S
solarium
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
common
solarium
Commits
2e60f969
Commit
2e60f969
authored
Dec 27, 2017
by
Markus Kalkbrenner
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' of
https://github.com/bpolaszek/solarium
into bpolaszek-develop
parents
d3b40c8b
18b69852
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
3 deletions
+19
-3
library/Solarium/Core/Query/Helper.php
library/Solarium/Core/Query/Helper.php
+3
-3
tests/Solarium/Tests/Core/Query/HelperTest.php
tests/Solarium/Tests/Core/Query/HelperTest.php
+16
-0
No files found.
library/Solarium/Core/Query/Helper.php
View file @
2e60f969
...
@@ -139,7 +139,7 @@ class Helper
...
@@ -139,7 +139,7 @@ class Helper
*
*
* @see http://lucene.apache.org/solr/api/org/apache/solr/schema/DateField.html
* @see http://lucene.apache.org/solr/api/org/apache/solr/schema/DateField.html
*
*
* @param int|string|\DateTime
$input accepted formats: timestamp, date string or DateTim
e
* @param int|string|\DateTime
Interface $input accepted formats: timestamp, date string or DateTime / DateTimeImmutabl
e
*
*
* @return string|boolean false is returned in case of invalid input
* @return string|boolean false is returned in case of invalid input
*/
*/
...
@@ -148,7 +148,7 @@ class Helper
...
@@ -148,7 +148,7 @@ class Helper
switch
(
true
)
{
switch
(
true
)
{
// input of datetime object
// input of datetime object
case
$input
instanceof
\DateTime
:
case
$input
instanceof
\DateTime
Interface
:
// no work needed
// no work needed
break
;
break
;
...
@@ -180,7 +180,7 @@ class Helper
...
@@ -180,7 +180,7 @@ class Helper
// handle the filtered input
// handle the filtered input
if
(
$input
)
{
if
(
$input
)
{
// when we get here the input is always a datetime object
// when we get here the input is always a datetime object
$input
->
setTimezone
(
new
\DateTimeZone
(
'UTC'
));
$input
=
$input
->
setTimezone
(
new
\DateTimeZone
(
'UTC'
));
$iso8601
=
$input
->
format
(
\DateTime
::
ISO8601
);
$iso8601
=
$input
->
format
(
\DateTime
::
ISO8601
);
$iso8601
=
strstr
(
$iso8601
,
'+'
,
true
);
//strip timezone
$iso8601
=
strstr
(
$iso8601
,
'+'
,
true
);
//strip timezone
$iso8601
.=
'Z'
;
$iso8601
.=
'Z'
;
...
...
tests/Solarium/Tests/Core/Query/HelperTest.php
View file @
2e60f969
...
@@ -321,6 +321,22 @@ class HelperTest extends \PHPUnit_Framework_TestCase
...
@@ -321,6 +321,22 @@ class HelperTest extends \PHPUnit_Framework_TestCase
);
);
}
}
public
function
testFormatDateInputDateTimeImmutable
()
{
date_default_timezone_set
(
"UTC"
);
// prevent timezone differences
$this
->
assertFalse
(
$this
->
helper
->
formatDate
(
new
\stdClass
()),
'Expect any other object not to be accepted'
);
$this
->
assertEquals
(
$this
->
mockFormatDateOutput
(
strtotime
(
'2011-10-01'
)),
$this
->
helper
->
formatDate
(
new
\DateTimeImmutable
(
'2011-10-01'
)),
'Expects formatDate with DateTimeImmutable input to output ISO8601 with stripped timezone'
);
}
public
function
testFormatDate
()
public
function
testFormatDate
()
{
{
//check if timezone is stripped
//check if timezone is stripped
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment