Make WordPress Core

Opened 6 years ago

Closed 5 years ago

#43530 closed defect (bug) (duplicate)

date_i18n() outputs invalid Swatch Internet Time

Reported by: rarst's profile Rarst Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Date/Time Keywords: has-unit-tests
Focuses: Cc:

Description

Since date_i18n() operates with "WordPress timestamp" which is summed up with time zone offset, it doesn't produce correct result for B format which doesn't vary with time zone.

<?php
var_dump( date( 'B' ), date_i18n( 'B' ) );
// string(3) "692" string(3) "775"

Honestly with all the outstanding problems with the function it's more of a curiosity than urgent problem, but something that needs to be considered if it's ever fixed or replaced.

Attachments (2)

added-test-date_i18n-swatch-internet-time.diff (741 bytes) - added by remcotolsma 6 years ago.
Added test for date_i18n() outputs invalid Swatch Internet Time ticket 43530.
wp-timezone-simple-date-i18n-v2.diff (4.8 KB) - added by remcotolsma 6 years ago.
Path from ticket 24730 can also fix this ticket?

Download all attachments as: .zip

Change History (5)

@remcotolsma
6 years ago

Added test for date_i18n() outputs invalid Swatch Internet Time ticket 43530.

@remcotolsma
6 years ago

Path from ticket 24730 can also fix this ticket?

#1 @pento
6 years ago

  • Keywords has-patch has-unit-tests added
  • Version trunk deleted

#2 @Rarst
6 years ago

  • Keywords has-patch removed

This isn't ready, patch just refers to work in #24730 on timezone retrieval and I don't think we got it sufficiently robust on PHP 5.2 (if that's even possible).

But! If core is bumped to PHP 5.6 that problem simply goes away, so I am suggesting we hold on for that.

#3 @Rarst
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

This should be solved by general refactor in #25768, added the unit test there.

Note: See TracTickets for help on using tickets.