[wp-trac] [WordPress Trac] #28992: mysql2date() return empty string not false

WordPress Trac noreply at wordpress.org
Sun Oct 4 19:47:44 UTC 2015


#28992: mysql2date() return empty string not false
-------------------------------------------------+-------------------------
 Reporter:  pbearne                              |       Owner:
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Future
Component:  Date/Time                            |  Release
 Severity:  normal                               |     Version:  3.8
 Keywords:  needs-testing dev-feedback needs-    |  Resolution:
  refresh                                        |     Focuses:
-------------------------------------------------+-------------------------
Changes (by aaroncampbell):

 * keywords:  has-patch needs-testing dev-feedback => needs-testing dev-
     feedback needs-refresh
 * milestone:  Awaiting Review => Future Release


Comment:

 The inline documentation for `mysql2date` was updated in [29344] as part
 of #28310, and two unit tests were added.

 My initial thought was that I didn't want to change the return in any
 case, but instead just document them. Having said that, I don't like how
 inconsistent this is:

 {{{
 #!php
 mysql2date( 'Y-m-d', '' ); // false - expected

 mysql2date( 'U', 'not a date' ); // false - expected
 mysql2date( 'G', 'not a date' ); // false - expected
 mysql2date( 'Y-m-d', 'not a date' ); // "2015-10-04" (current date)?!

 mysql2date( 'U', '2012-12-30' ); // 1356825600 - expected
 mysql2date( 'G', '2012-12-30' ); // 1356825600 - expected
 mysql2date( 'Y-m-d', '2012-12-30' ); // "2012-12-30" - expected

 mysql2date( 'U', '1' ); // false - expected
 mysql2date( 'G', '1' ); // false - expected
 mysql2date( 'Y-m-d', '1' ); // "2015-10-04" (current date)?!
 }}}

 I don't like how "1" and "not a date" return false if the format string is
 U or G, and current date for any other format string. Does anyone have any
 particularly compelling reasons for having dates that `strtotime` doesn't
 understand return false vs empty string or anything else?

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28992#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list