[Owncloud] Fwd: Calendar Timezone issues - No Australia?

Stephen Rees-Carter stephen at rees-carter.net
Wed Oct 5 23:41:27 UTC 2011


Ok, I think I figured out how to do a Merge Request...
https://gitorious.org/owncloud/owncloud/merge_requests/55

Thanks,
~Stephen

---------- Forwarded message ----------
From: Stephen Rees-Carter <stephen at rees-carter.net>
Date: Thu, Oct 6, 2011 at 9:30 AM
Subject: Calendar Timezone issues - No Australia?
To: owncloud at kde.org


Hi all,

I've found an issue with the Calendar Timezone selection under User
Settings. There are no Australian Timezones in the list.

I did some digging in the code and I found the issue is in this file:
    /apps/calendar/templates/settings.php

Starting at line 18:

                foreach($_['timezones'] as $timezone):
                        if ( preg_match(
'/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//',
$timezone ) ):
                                $ex=explode('/', $timezone, 2);//obtain
continent,city
                                if ($continent!=$ex[0]):
                                        if ($continent!="") echo
'</optgroup>';
                                        echo '<optgroup
label="'.$ex[0].'">';
                                endif;
                                $city=$ex[1];
                                $continent=$ex[0];
                                echo '<option
value="'.$timezone.'"'.($_['timezone'] == $timezone?'
selected="selected"':'').'>'.$city.'</option>';
                        endif;
                endforeach;?>

The list of continents being shown is hard-coded, and Australia isn't on the
list.
Adding 'Australia' into that list of continents fixes the issue, but I am
wondering why is that list hard-coded at all?
I assume the only reason to check for those words is to ensure we have the
format: "Continent/City".

The two solutions to this problem, which aren't simply adding Australia to
the list, that I can think of are:

1) Replace the preg_match() IF condition with a strpos() condition to check
for the '/'. It will ensure that only timezones in the right format are
shown without having to hardcode them all.

    REPLACE
        if ( preg_match(
'/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//',
$timezone ) ):

    WITH
        if (strpos($timezone, "/")):

2) Or we can get smarter and manually put all timezones without a Continent
into an 'Other' category.

    REPLACE
        if ( preg_match(
'/^(America|Antartica|Arctic|Asia|Atlantic|Europe|Indian|Pacific)\//',
$timezone ) ):
                $ex=explode('/', $timezone, 2);//obtain continent,city
                if ($continent!=$ex[0]):
                        if ($continent!="") echo '</optgroup>';
                        echo '<optgroup label="'.$ex[0].'">';
                endif;
                $city=$ex[1];
                $continent=$ex[0];
                echo '<option value="'.$timezone.'"'.($_['timezone'] ==
$timezone?' selected="selected"':'').'>'.$city.'</option>';
        endif;

    WITH
            $ex=explode('/', $timezone, 2);//obtain continent,city

            if (!isset($ex[1])) {
                    $ex[1] = $ex[0];
                    $ex[0] = "Other";
            }

            if ($continent!=$ex[0]):
                    if ($continent!="") echo '</optgroup>';
                    echo '<optgroup label="'.$ex[0].'">';
            endif;
            $city=$ex[1];
            $continent=$ex[0];
            echo '<option value="'.$timezone.'"'.($_['timezone'] ==
$timezone?' selected="selected"':'').'>'.$city.'</option>';


I've never used Gitorious, and I'm pretty new to Git, so I don't know how
I'd go about signing up to make these changes myself...
I'm happy to learn if anyone wants to teach me :)

Thanks,
~Stephen

-- 
Stephen Rees-Carter ~ Valorin
http://stephen.rees-carter.net/



-- 
Stephen Rees-Carter ~ Valorin
http://stephen.rees-carter.net/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/owncloud/attachments/20111006/0c710c50/attachment.html>


More information about the Owncloud mailing list