[wp-trac] [WordPress Trac] #20973: date_i18n() is wrong for certain formats, escapes sequences and daylight saving time (was: date_i18n() produces invalid output for shorthand formats)

WordPress Trac noreply at wordpress.org
Tue Oct 29 22:53:15 UTC 2013


#20973: date_i18n() is wrong for certain formats, escapes sequences and daylight
saving time
-------------------------------------------------+-------------------------
 Reporter:  Rarst                                |       Owner:
     Type:  defect (bug)                         |      Status:  reopened
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Date/Time                            |  Review
 Severity:  major                                |     Version:  3.4
 Keywords:  has-patch dev-feedback needs-        |  Resolution:
  testing                                        |
-------------------------------------------------+-------------------------
Changes (by raubvogel):

 * severity:  normal => major


Comment:

 Beside the format and escaping issue I found another issue maybe:
 {{{
 /*
 * Test is called in time zone Europe/Berlin at a date where daylight
 saving time is off!
 * (Daylight saving time in Europe/Berlin was switched off at 2013-10-27)
 */
 // results 2013-10-29T22:15:03+01:00 while daylight saving time
 (Europe/Berlin) is off; result is correct
 echo(date_i18n('Y-m-d\TH:i:sP', 1383084903));
 // results 2013-10-11T19:37:20+01:00 while daylight saving time
 (Europe/Berlin) is on; result is wrong! should be +02:00!
 echo(date_i18n('Y-m-d\TH:i:sP', 1381520240));
 }}}
 As you can see the time zone offset is sometimes wrong. Actually it
 depends on the current daylight saving time.

 Is issue comes from wordpress\wp-includes\functions.php:127 in
 {{{date_i18n()}}}:
 {{{
 $date_object = date_create( null, $timezone_object );
 }}}
 The date object created with the current time stamp ("null = now"). This
 is wrong. It has to be created with the time stamp from {{{date_i18n()}}}
 parameter {{{$unixtimestamp}}}.

 For now we have 3 issues at {{{date_i18n()}}} which is annoying (at least
 for my German blogs). I set the severity of this ticket to "major" and
 changed the summary according the 3 issues.

 I tested the daylight saving time issue with my patch. It worked! I think
 some core developer really should have a look at this ticket. And it would
 be nice if other people could test my patch. Thx!

--
Ticket URL: <http://core.trac.wordpress.org/ticket/20973#comment:34>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list