Results 1 to 5 of 5

Thread: Daylight Savings Time FIX - Sugar4

  1. #1
    sdeller is offline Junior Member
    Join Date
    Dec 2005
    Posts
    2

    Default Daylight Savings Time FIX - Sugar4

    There was stll a bug in Sugar 4 with regard to DST (at least with Pacific/Auckland (GMT+12) (+DST) anyway)

    Server time is correct, all MSQL storage times are correct (UTC) but Sugar would still not detect that we are in DST here in NZ, and always display everything 1hr wrong.

    Found the fault to be the result of a function in /include/TimeDate.php not recognising that we are indeed in DST

    The attached TimeDate.php appears to work so far... Hopefully this may help someone else too.

    Techical Explanation Follows:
    The inDST function checks to see whether the supplied date is in the Daylight Savings date range.

    This function calls another function called “getDSTRange” which gets the user’s start and end dates for daylight savings.

    In the TimeZones definition file, the Pacific/Auckland start month is October and the end month is March.

    The getDSTRange was pulling out these start/end dates and appending the current year (2006) – then passing them back to the inDST function.

    The inDST function would then take the supplied date (the date it was checking) and pass it through this if statement:

    If (suppliedDate >= StartDST AND StartDST > EndDST) OR (suppliedDate >= StartDST AND suppliedDate < EndDST)



    The StartDST is always going to be greater than the EndDST but the SuppliedDate will only be greater than StartDST in October, November and December.

    This means that for January and February – it’s up to the second part of the if statement to return true:

    The SuppliedDate will only be greater than StartDST in October, November and December.

    This means that this IF statement would only ever return true in October, November, and December.

    The solution was to modify the START DST time, and change it to the previous year:

    If (09/01/2006 >= 01/10/2005 AND 01/10/2005 > 01/03/2006) OR (09/01/2006 >= 01/10/2005 AND 09/01/2006 < 01/03/2006)
    Attached Files Attached Files

  2. #2
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: Daylight Savings Time FIX - Sugar4

    Great fix, I would imagine that it is possible other time zones are affected by this bug. Did you enter it in bugs.sugarcrm.com?
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  3. #3
    sugarchris's Avatar
    sugarchris is offline Sugar Community Member
    Join Date
    Sep 2005
    Location
    San Francisco, CA
    Posts
    861

    Default Re: Daylight Savings Time FIX - Sugar4

    Hi sdeller,

    Thanks for the headsup and fix for folks. We ran into something similar, and have fixed it, but in any case, I've forwarded this thread to the devs who made the above fix. In any case, thanks for bringing it to our attention. A bug/fix may be forth coming

  4. #4
    WayneSugar's Avatar
    WayneSugar is offline Sugar Community Member
    Join Date
    Oct 2005
    Posts
    155

    Default Re: Daylight Savings Time FIX - Sugar4

    Thanks sdeller. We have been aware of this problem and are working on the fix.

    Please note that using sdeller's excellent patch will not modify your existing data. I would advise anybody with existing 4.0 data to wait for the forthcoming SugarCRM fix which will correctly adjust existing data.

    Also, I believe that the bug only affects users in the southern hemisphere where the DST start/end times are inverse of northern.
    Wayne Pan
    Software Eng.

  5. #5
    sdeller is offline Junior Member
    Join Date
    Dec 2005
    Posts
    2

    Default Re: Daylight Savings Time FIX - Sugar4

    Great news, I am glad we could give something back. I'll look at the bug area and open one up if not done so already.

    UPDATE: It looks like this issue is already apparent and there is a fix in version 4.0.1, but not sure if 4.0.1 is available for download yet....

    Cheers
    Sam
    Last edited by sdeller; 2006-01-09 at 11:33 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •