Categorized | News, OOP, PHP

PEAR::Date issues

Posted on 15 July 2005 by Demian Turner

At work we use PEAR::Date all over the place, and while the package is fine for most things, when it comes to timezone handling and daylight savings time offsets, there are some serious bugs that have been open in the PEAR bugtracker for around one year.

Andrew Hill writes in detail about a problem he’s trying to resolve regarding the TZ environment variable not being set in many linux systems and how this causes PEAR::Date to blow up when in DST.

Have similar experiences? Feel free to comment here since his ezPublish comments don’t work for anonymous users.

Bookmark and Share

10 Comments For This Post

  1. Pierre Says:

    I replied many times about this issue. The choose we made about usint ENV for the Timezones was a mistake. put/set env in threaded environments is not safe, and can even occur to segfaults. If one has a nice solution keeping BC, I will take it.

    I consider for now to add a mode to date 1.x branche and break bc. Then I can solve this problem (and 2 other related).

    –Pierre

  2. Davey Shafik Says:

    Won’t this all be moot when ext/date makes it into a release?

    Regardless, what do you hope to achieve with this blog Demian? (serious question!) There is nothing stopping you contributing fixes for this bug.

    – Davey

  3. Demian Turner Says:

    My colleague Andrew, mentioned in the 2nd paragraph, has contributed a number of patches that are sitting in pear bugtracker. What we’re trying to find out is other people’s experience/problems with the lib. A single solution that works in php 4 and 5 that doesn’t break BC so far has not been found. This blog is for sharing PHP-related knowledge and projects, not dissimilar to yours :-)

  4. Pierre Says:

    Davey, I personnally like this kind of posts, the idea being to reach a larger public. Maybe an abvious solution will come out soon :).

    About ext/date, I’m working on the specs for this extension with Derick (Well, Derick is waiting for me this time, I’m a bit busy with other urgent things). But ext/date is 5.1.0+ only (after 5.1.0 for new functions), I like to have a solution for php4.

    That’s why I consider to add a flag (default to false) which will break BC with pear::date 1.3.x. Then I can make some real changes and optimisations.

    –Pierre

  5. Pierre Says:

    stupid comment, can you at least do some nl2br for the comments? :)

  6. Demian Turner Says:

    totally agreed – this is quite a recent s9y, i should send them a patch 😉

  7. Andrew Hill Says:

    Pierre, I agree that at some stage, a thread-safe solution needs to be found. But, as you say, the current PEAR::Date package isn’t thread safe, so, given that, users of the package want to be able to use it in a non-threaded environment. I believe that the process of ensuring the TZ variable is set before using PEAR::Date is a backwards compatible fix for the current package, that works, for both PHP4 and PHP5. However, I also think that having the proposed patch for Bug #2338, as well as a similar patch for Date_Span::setFromDateDiff(), would make users of the PEAR::Date package under PHP5 very happy, as it means they can use PEAR::Date without it changing the parameter time zones, and also allowing the package to continue to work in PHP4. – Andrew

  8. Andrew Hill Says:

    Heh, at least you have comments that work. I really need to get off my butt, huh? :-)

  9. Davey Shafik Says:

    I see no problem with that, I was merely curious as to what he hoped to achieve, if we don’t know, how can we help? :)

    – Davey

  10. fornax.net Says:

    My day job involves working on an OSS project called Max Media Manager, written in PHP.The project involves the collection and presentation of statistics, and thus, dates and times are rather important. Ideally, we want to record all dates and times in th

Leave a Reply

Categories

Books

Demian Turner's currently-reading book recommendations, reviews, favorite quotes, book clubs, book trivia, book lists

Facebook