Ticket #1484156 (assigned Patches)

Opened 22 months ago

Last modified 4 months ago

apply daylight saving only when date is on daylight saving time

Reported by: runico Owned by: till
Priority: 5 Milestone: 0.2-stable
Component: Client Scripts Version: 0.1-beta2
Severity: normal Keywords:
Cc:

Description

When daylight saving is activated one hour is added to all dates, but only should be added when the date is on daylight saving time. Now I must disable daylight saving and I will have to enable it in april.

Attachments

daylight.diff (0.5 kB) - added by runico 22 months ago.
Patch for fix it

Change History

Changed 22 months ago by runico

Patch for fix it

Changed 22 months ago by runico

  • type changed from Bugs to Patches

Changed 22 months ago by tcat

Here is an other way to calculate daylight saving time (doesn\'t depends on locale settings):

  //adjust daylight saving
  if ($CONFIG['dst_active']) {
    $year = date("Y", $timestamp);
    $tmp = strtotime("last Sunday", mktime(0, 0, 0, 4, 1, $year));
    $last_sunday_march = mktime(2, 0, 0, date("m", $tmp), date("d", $tmp), date("Y", $tmp));
    $tmp = strtotime("last Sunday", mktime(0, 0, 0, 11, 1, $year));
    $last_sunday_october = mktime(3, 0, 0, date("m", $tmp), date("d", $tmp), date("Y", $tmp));
    if (($timestamp >= $last_sunday_march) && ($timestamp + 3600 < $last_sunday_october)) $timestamp += 3600; //summertime
  }

Changed 21 months ago by jpingle

DST is changing this year in the US, and changes in other locations from time to time. Hardcoding dates is probably not a good idea.

Part of the issue with this ticket is whether a system's clock is set to UTC, in which case the system doesn't know or care about DST, of if the system clock is set to Local Time in which case no changes to the clock need to be made.

If you hardcode DST, instead of relying on the system's time zone definitions, it may fix it for some people and break it for others. You could end up an hour or two off in any direction, if people on the same system were in wildly different places.

Changed 8 months ago by seansan

  • milestone set to 0.1.1

Review in 1.1

Changed 7 months ago by till

  • owner set to till
  • status changed from new to assigned

I see what you mean. I'll look into this.

Changed 7 months ago by till

This is extremely hard to guess.

date('I', $foo)

Should return 1 or 0, if a date is in DST, or not. A TZ has to be set for this.

Changed 5 months ago by alec

I think it should be hardcoded.

Changed 4 months ago by ulysses.almeida

I think we better use timezone support from PHP 5.1.0 and above. Users could choose a timezone from timezone_identifiers_list(); Than roundcube can calculate better when some date is or not in DST considering users timezone. The only tradeoff is, RC admins will need to keep their timezonedb updated, because, as already mentioned, some countries change their DST yearly. But probably he already need to keep his server tzdb updated.

Note: See TracTickets for help on using tickets.