date_i18n() is wrong for certain formats, escapes sequences and daylight saving time
|Reported by:||raubvogel||Owned by:|
|Component:||Date/Time||Keywords:||has-patch needs-testing needs-unit-tests|
date_i18n() returns wrong values in the following cases:
- If time zone is not GMT date_i18n( 'c', time() ) does not return the correct difference to GMT part, e.g., 2013-10-30T14:00:00+00:00 instead of 2013-10-30T14:00:00+01:00.
- The time zone offset is sometimes wrong:
/* * 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));
- date_i18n( 'D | \D | \\D | \\\D | \\\\D | \\\\\D | \\\\\\D' ) does not escaping properly.
The implementation of date_i18n() is not very well at all. Therefore it was completely rewritten solving the issues above. Performance should be better too. I added some tests too.
This ticket is a result of the discussion in ticket #20973. You can find a more detailed discussion there.
Change History (6)
- Keywords needs-unit-tests added; dev-feedback removed
- Milestone changed from Awaiting Review to Future Release