Re: [Tiki-devel] Sorry, timezones again

Jonny Bradley via TikiWiki-devel <[email protected]>
Newsgroups gmane.comp.cms.tiki.devel
Message-ID <[email protected]>
Hi Victor

Thanks, yes i investigated that commit and added the if tzname part to the calendar item edit code, but it didn't seem to make any difference - i think it's ok until it gets to the TikiLib::date_format function which messes things up (and i don't think tracker date fields use that do they?)

I agree, changing that function seems dangerous, and especially back porting it to 24.x but i can't see another way of doing it unless i disconnect the calendar code from it (leaving the other 200+ uses being wrong).

Anyway, thanks for the input, i'll keep hammering away at it (we need it to work properly for 24.1 at least!)

jonny





> On 21 Mar 2022, at 20:52, Victor Emanouilov via TikiWiki-devel <[email protected]> wrote:
> 
> Hi Jonny,
> 
> I'd rather not change that function. Can you check my 1 week old commit here:
> 
> https://gitlab.com/tikiwiki/tiki/-/commit/02307e79b8912b36abe1e6b9da749e8961a7668c
> 
> It solves the DST issue in the JsCalendar tracker field and I think the same is needed in the calendar controller. The problem is that jscalendar smarty function (which is used by both the tracker field and calendar and I believe a bunch of other places) was using only browser-based timezone offset which is different when DST kicks in. The fix contains both - the timezone offset and the time zone name. This will make sure time will be correct no matter if DST is on or off. However, we need backend handling code to actually use the time zone name. See the additional code in JsCalendar::getFieldData method. I think similar code is needed when saving a calendar event timestamp which looks up tzoffset.
> 
> HTH,
> Victor
> 
> On 3/18/22 1:46 PM, Jonny Bradley via TikiWiki-devel wrote:
>> Hi all, mostly Victor i think, but for general discussion...
>> 
>> I have another couple of issues with timezones in calendars, quite easily reproducible here for me... i'm in GMT Europe/London zone, and my php says default timezone is UTC and the tiki is set to London and "automatically detected time zone" which also is Europe/London.
>> 
>> If i create a calendar event for after 27th March (when our clocks go forward to British Summer Time/BST) at 12:00 noon, it shows as being 13:00, so definitely incorrect. If i apply the patch below open \TikiLib::date_format, which combines creating the "tikidate" and setting the timezone at the same time, it all looks ok... so should i commit that? This function is used 220 times in tiki at least, and timezones scare me!
>> 
>> A side effect of this is that i have a recurring weekly noon event that starts in GMT but continues into "summer time" and with this patch the BST ones show as being at 11:00, so they would need correcting, because they looked ok before...
>> 
>> I know i'm out of my depth here, so would like some reassurance or pointers in the right direction please :)
>> 
>> TIA
>> 
>> jonny
>> ---
>> 
>> 
>> 
>> Index: lib/tikilib.php
>> IDEA additional info:
>> Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
>> <+>UTF-8
>> ===================================================================
>> diff --git a/lib/tikilib.php b/lib/tikilib.php
>> --- a/lib/tikilib.php	(revision 632dbe0774db70d405de13f743c0fe35a697dd9d)
>> +++ b/lib/tikilib.php	(date 1647603391982)
>> @@ -5672,19 +5672,13 @@
>>          }
>>            $tikidate = TikiLib::lib('tikidate');
>> +        $tz = $tikilib->get_display_timezone($_user);
>>          try {
>> -            $tikidate->setDate($timestamp, 'UTC');
>> +            $tikidate->setDate($timestamp, $tz);
>>          } catch (Exception $e) {
>>              return $e->getMessage();
>>          }
>>  -        $tz = $tikilib->get_display_timezone($_user);
>> -
>> -        // If user timezone is not also in UTC, convert the date
>> -        if ($tz != 'UTC') {
>> -            $tikidate->setTZbyID($tz);
>> -        }
>> -
>>          $return = $tikidate->format($format, $is_strftime_format);
>>          if ($is_strftime_format) {
>>              $currentUserDateByFormat[ $format . $timestamp ] = $return;
>> 
>> 
>> 
>> _______________________________________________
>> TikiWiki-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
> 
> 
> _______________________________________________
> TikiWiki-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tikiwiki-devel
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.