Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
ae1bd393
Commit
ae1bd393
authored
Nov 28, 2014
by
Carsten Brandt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adjusted missing return for fix #6263
parent
9ae538e6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
Formatter.php
framework/i18n/Formatter.php
+1
-1
FormatterDateTest.php
tests/unit/framework/i18n/FormatterDateTest.php
+15
-0
No files found.
framework/i18n/Formatter.php
View file @
ae1bd393
...
...
@@ -601,7 +601,7 @@ class Formatter extends Component
// checking for DateTime and DateTimeInterface is not redundant, DateTimeInterface is only in PHP>5.5
if
(
$value
===
null
||
$value
instanceof
DateTime
||
$value
instanceof
DateTimeInterface
)
{
// skip any processing
return
$value
;
return
$
checkTimeInfo
?
[
$value
,
true
]
:
$
value
;
}
if
(
empty
(
$value
))
{
$value
=
0
;
...
...
tests/unit/framework/i18n/FormatterDateTest.php
View file @
ae1bd393
...
...
@@ -63,6 +63,13 @@ class FormatterDateTest extends TestCase
$this
->
assertSame
(
date
(
'n/j/y'
,
$value
),
$this
->
formatter
->
asDate
(
$value
,
'short'
));
$this
->
assertSame
(
date
(
'F j, Y'
,
$value
),
$this
->
formatter
->
asDate
(
$value
,
'long'
));
$value
=
new
DateTime
();
$this
->
assertSame
(
date
(
'M j, Y'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDate
(
$value
));
$this
->
assertSame
(
date
(
'Y/m/d'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDate
(
$value
,
'php:Y/m/d'
));
$this
->
assertSame
(
date
(
'm/d/Y'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDate
(
$value
,
'MM/dd/yyyy'
));
$this
->
assertSame
(
date
(
'n/j/y'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDate
(
$value
,
'short'
));
$this
->
assertSame
(
date
(
'F j, Y'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDate
(
$value
,
'long'
));
// empty input
$this
->
assertSame
(
'Jan 1, 1970'
,
$this
->
formatter
->
asDate
(
''
));
$this
->
assertSame
(
'Jan 1, 1970'
,
$this
->
formatter
->
asDate
(
0
));
...
...
@@ -89,6 +96,10 @@ class FormatterDateTest extends TestCase
$this
->
assertSame
(
date
(
'g:i:s A'
,
$value
),
$this
->
formatter
->
asTime
(
$value
));
$this
->
assertSame
(
date
(
'h:i:s A'
,
$value
),
$this
->
formatter
->
asTime
(
$value
,
'php:h:i:s A'
));
$value
=
new
DateTime
();
$this
->
assertSame
(
date
(
'g:i:s A'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asTime
(
$value
));
$this
->
assertSame
(
date
(
'h:i:s A'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asTime
(
$value
,
'php:h:i:s A'
));
// empty input
$this
->
assertSame
(
'12:00:00 AM'
,
$this
->
formatter
->
asTime
(
''
));
$this
->
assertSame
(
'12:00:00 AM'
,
$this
->
formatter
->
asTime
(
0
));
...
...
@@ -114,6 +125,10 @@ class FormatterDateTest extends TestCase
$this
->
assertSame
(
date
(
'M j, Y g:i:s A'
,
$value
),
$this
->
formatter
->
asDatetime
(
$value
));
$this
->
assertSame
(
date
(
'Y/m/d h:i:s A'
,
$value
),
$this
->
formatter
->
asDatetime
(
$value
,
'php:Y/m/d h:i:s A'
));
$value
=
new
DateTime
();
$this
->
assertSame
(
date
(
'M j, Y g:i:s A'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDatetime
(
$value
));
$this
->
assertSame
(
date
(
'Y/m/d h:i:s A'
,
$value
->
getTimestamp
()),
$this
->
formatter
->
asDatetime
(
$value
,
'php:Y/m/d h:i:s A'
));
// empty input
$this
->
assertSame
(
'Jan 1, 1970 12:00:00 AM'
,
$this
->
formatter
->
asDatetime
(
''
));
$this
->
assertSame
(
'Jan 1, 1970 12:00:00 AM'
,
$this
->
formatter
->
asDatetime
(
0
));
...
...
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