Issues

ZF-4490: Zend_Date::getDate() returns non-zero time part for dates not in UTC

Issue Type:

Bug

Created:

2008-10-05T02:40:02.000+0000

Last Updated:

2011-09-07T16:01:28.000+0000

Status:

Resolved

Fix version(s):

1.7.0 (17/Nov/08)

Reporter:

Jaka Jancar (jaka)

Assignee:

Thomas Weidner (thomas)

Tags:

Zend_Date

Related issues:

Attachments:

Description

For Zend_Dates in a timezone other than UTC, getDate() doesn't return a date with 0 time part, as described in docu, but instead 0 + time zone base offset (without DST).

I don't know if this is intended or not. If it is, it should be documented in the documentation.

Example of when this is a problem:
You have a set of objects and want to select only those whose time property is today. So you filter using {{(time >= Zend_Date::now()- >getDate()->getTimestamp() && time < ...)}}. But this will not display what the user considers "today" (what is today in the current timezone).

The bug still persists as of 1.11.10. Precisely, the result of getDate() is 1 hour off when DST is in effect for the given date. For dates without DST or when the timezone is set to UTC/GMT, the result is correct. Example:

The substitute solution with setting the time to midnight works either way. getDate() itself is currently unusable for DST-aware timezones.

The unit test only checks for 2002-01-04 (no DST) and therefore succeeds. A second check with a DST date is required for a full test. Additionally, the checks should be performed with timezone set to both UTC and a DST-aware timezone. The current test appears to use Indian/Maldives, which did NOT show the erratic behavior with my own test script. No DST on the maldives, I suppose. I'd recommend a timezone that is more than 1 hour away from UTC, so that it's clear whether the offset comes from the timezone or from DST.

The inconsistency of this bug's history may result from the use of Zend_Date::now() for testing. The reports come from mid-October and August (DST in effect), while the fix was made in November (no DST, no erratic behavior).