WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#8153 closed defect (bug) (fixed)

Use localized dates on General Options page

Reported by: nbachiyski Owned by:
Milestone: 3.1 Priority: normal
Severity: normal Version:
Component: I18N Keywords: has-patch, needs-testing
Focuses: Cc:

Description

In options-general.php dates and times are get from the vanilla date() and gmdate() PHP functions, which don't honor the translations of months and weekdays.

The patch also adds GMT option for date_i18n().

Attachments (5)

localized-dates-options-general.diff (4.2 KB) - added by nbachiyski 7 years ago.
localized-dates-options-general-fixup.diff (721 bytes) - added by nbachiyski 7 years ago.
Make second argument of date_i18n optional
proper-current-time-for-date_i18n.diff (1.8 KB) - added by nbachiyski 7 years ago.
If timestamp is missing use current time + offset and set gmt to true, so that the dates are shown properly. Also, use the right function in all places
bring-T-date-format-back.diff (969 bytes) - added by nbachiyski 5 years ago.
bring-T-date-format-back.2.diff (1.4 KB) - added by nbachiyski 5 years ago.

Download all attachments as: .zip

Change History (29)

comment:1 @nbachiyski7 years ago

  • Keywords has-patch commit added

comment:2 @nbachiyski7 years ago

  • Keywords commit removed

comment:3 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [9616]) Use localized dates on General Options page. Props nbachiyski. fixes #8153

comment:4 @lloydbudd7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Generates warnings:

Warning: Missing argument 2 for date_i18n(), called in wp-admin/options-general.php on line 124 and defined in wp-includes/functions.php on line 115

@nbachiyski7 years ago

Make second argument of date_i18n optional

comment:5 @ryan7 years ago

I think the unixtimestamp arg just needs a default of zero.

comment:6 @ryan7 years ago

Oops, you beat me to it. :-)

comment:7 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [9618]) Fix warnings. Props nbachiyski. fixes #8153

comment:8 @nbachiyski7 years ago

If it defaulted to 0, and we interpreted 0 as current time, we wouldn't be able to call it for Jan 1, 1970 00:00:00.

comment:9 @markjaquith7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

This generates incorrect dates for the timezone-shifted date.

UTC time is 2008-11-12 16:11:44 UTC -4 is 2008-11-12 11:11:44

16 - 4 != 11

comment:10 @ryan7 years ago

(In [9647]) Show user specified offset, not server offset, when displaying time. see #8153

comment:11 @nbachiyski7 years ago

Now it was your turn to commit it seconds before me attaching the file :-)

comment:12 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

@nbachiyski7 years ago

If timestamp is missing use current time + offset and set gmt to true, so that the dates are shown properly. Also, use the right function in all places

comment:13 @nbachiyski7 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

What do you think if reverting [9647] and using the fixed version in the patch, instead?

Being able to use just date_i18n(format); sounds very appealing to me.

comment:14 @jacobsantos7 years ago

  • Keywords needs-unittests added

comment:15 @jacobsantos7 years ago

  • Keywords needs-unit-tests added; needs-unittests removed

comment:16 @ryan7 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

(In [9742]) date_i18n() fixes. Props nbachiyski. fixes #8153

comment:17 @ryan7 years ago

I put in a conditional to use time() if $gmt and current_time() if not. Otherwise, you couldn't get UTC Time.

comment:18 @nacin5 years ago

  • Keywords has-patch needs-unit-tests removed

comment:19 @nbachiyski5 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Using gmdate() when the timezone is different from GMT breaks the T format modifier.

Here is a patch, which tries to use the current timezone settings in order to manually replace it.

comment:20 @nbachiyski5 years ago

Updated patch to include all timezone format letters, except T.

comment:21 @westi5 years ago

  • Cc westi added
  • Milestone changed from 2.7 to 3.1

Changing milestone to 3.1 from 2.7 as we still have issues and a new patch

comment:22 @jane5 years ago

  • Keywords has-patch needs-testing added

comment:23 @nacin5 years ago

Marked #13974 as a duplicate.

comment:24 @westi5 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

[16203] - Restore the functionality of some of the other timezone format modifiers in date_i18n props nbachiyski.

Testing wise this has been running on WPCOM for a few weeks now without issues.

Note: See TracTickets for help on using tickets.