https://bugzilla.wikimedia.org/show_bug.cgi?id=32351

Van de Bugger <van.de.bug...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Attachment #9416|0                           |1
        is obsolete|                            |

--- Comment #2 from Van de Bugger <van.de.bug...@gmail.com> 2011-11-11 23:42:25 
UTC ---
Created attachment 9424
  --> https://bugzilla.wikimedia.org/attachment.cgi?id=9424
Patch v2.

Another attempt to the problem.

This patch implements following:

1. Both #time and #timel recognize and respect explicitly specified timezone:

{{ #time: ... | 2011-11-12 23:00 UTC }}
{{ #time: ... | 2011-11-12 23:00 Europe/Paris }}
{{ #time: ... | 2011-11-12 23:00 Europe/Moscow }}
etc.

2. If timezone is not explicitly specified, UTC is assumed.

3. #time output is UTC:

{{ #time:  Y-m-d H:i | 2011-11-12 23:00 Europe/Paris }} = 2011-11-12 22:00

4. #timel respects user preferences, not wiki default timezone
($wgLocaltimezone; wiki default timezone is used if user is not logged in):

{{ #timel: Y-m-d H:i | 2011-11-12 23:00 UTC }} = 2011-11-13 03:00

(Assumed user preferences is +04:00).

This differs from existing implementation:

1. There is a bug in current implementation. If PHP >= 5.2, explicitly
specified timezone is not respected. (However, if PHP < 5.2, it is respected).

2. #timel reports time in wiki default timezone. I changed this behaviour
intentionally. I think using user preferences is more useful than using wiki
timezone. At least, it is aligned with wiki behaviour: at the bottom of page
modification date is shown using user timezone, not wiki timezone.

3. Current implementation uses wiki default timezone if timezone is not
explicitly specified... (However, I did not tested it thoroughly.) BTW, there
are comments in funcsParserTests.txt:

> # fixme: #time seems to be accepting input as local time, which strikes me as 
> wrong

> Input times should probably be UTC, not local time

Anyway, exact semantic of #time and #timel was never precisely defined. The
only mention about timezones is:

> This function is identical to {{#time: ... }}, except that it uses the local
> time of the wiki (as set in $wgLocaltimezone) when no date is given.

----

Brion Vibber wrote:

> This would be a good candidate for adding some test cases to
> parserFunctionsTests.txt

Do you mean funcsParserTests.txt? This patch includes few tests for #time.
Problems:

1. There are no tests for #timel, because it depends on user preferences. If
user preferences are unknown, it is not possible to specify result.

2. It is not clear how to test both implementation branches -- for PHP >= 5.2
and PHP < 5.2.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
Wikibugs-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to