Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Tomáš Trávníček
doctrine-dbal
Commits
feedcfae
Commit
feedcfae
authored
Dec 21, 2013
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-415] More lenient parsing of DateTime by using date_create() as fallback.
parent
269d3e1f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
0 deletions
+26
-0
UPGRADE.md
UPGRADE.md
+12
-0
DateTimeType.php
lib/Doctrine/DBAL/Types/DateTimeType.php
+5
-0
DateTimeTest.php
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
+9
-0
No files found.
UPGRADE.md
View file @
feedcfae
# Upgrade to 2.5
## datetime Type uses date_create() as fallback
Before 2.5 the DateTime type always required a specific format, defined in
`$platform->getDateTimeFormatString()`
, which could cause quite some troubles
on platforms that had various microtime precision formats. Starting with 2.5
whenever the parsing of a date fails with the predefined platform format,
the
`date_create()`
function will be used to parse the date.
This could cause some troubles when your date format is weird and not parsed
correctly by
`date_create`
, however since databases are rather strict on dates
there should be no problem.
## Support for pdo_ibm driver removed
The
``pdo_ibm``
driver is buggy and does not work well with Doctrine. Therefore it will no
...
...
lib/Doctrine/DBAL/Types/DateTimeType.php
View file @
feedcfae
...
...
@@ -63,6 +63,11 @@ class DateTimeType extends Type
}
$val
=
\DateTime
::
createFromFormat
(
$platform
->
getDateTimeFormatString
(),
$value
);
if
(
!
$val
)
{
$val
=
date_create
(
$value
);
}
if
(
!
$val
)
{
throw
ConversionException
::
conversionFailedFormat
(
$value
,
$this
->
getName
(),
$platform
->
getDateTimeFormatString
());
}
...
...
tests/Doctrine/Tests/DBAL/Types/DateTimeTest.php
View file @
feedcfae
...
...
@@ -53,4 +53,13 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
$date
=
new
\DateTime
(
"now"
);
$this
->
assertSame
(
$date
,
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
));
}
public
function
testConvertsNonMatchingFormatToPhpValueWithParser
()
{
$date
=
'1985/09/01 10:10:10.12345'
;
$actual
=
$this
->
_type
->
convertToPHPValue
(
$date
,
$this
->
_platform
);
$this
->
assertEquals
(
'1985-09-01 10:10:10'
,
$actual
->
format
(
'Y-m-d H:i:s'
));
}
}
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