• Welcome to Simple Machines Community Forum. Please login or sign up.
December 08, 2021, 08:45:51 PM

News:

SMF 2.1 RC4 has been released! Try it out and help us test! :) Read more.


Profil Time Zones

Started by wintstar, August 21, 2021, 07:01:18 AM

Previous topic - Next topic

wintstar

How can I display the // Location name Berlin in the profile under time format?

You cannot see attachments on this board.
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Kindred

Is Berlin an actual timezone identifier?
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.<br /><br />"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

wintstar

It is Europe / Berlin.

As you can see in the linked links these are language strings of Location names in the Language file Timezones.english.php

Therefore my question where are these language stings used in the subdivision // Location names., how are they displayed in the selection menu. I want to display this language string $txt['Europe/Berlin'] = 'Berlin'; to the German user in the time zone selection field. The language string is available, how to display it for the German time zone.
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Sesquipedalian

September 02, 2021, 02:00:25 AM #3 Last Edit: October 30, 2021, 01:43:47 PM by Sesquipedalian
Which of these are you trying to do?

BeforeAfter
Option 1:[UTC+02:00] - Central European Time (CEST/CET)[UTC+02:00] - Berlin, Büsingen, Paris, Rome, Madrid, etc. (CEST/CET)
Option 2:[UTC+02:00] - Central European Time (CEST/CET)[UTC+02:00] - Berlin (CEST/CET)
[UTC+02:00] - Büsingen (CEST/CET)
[UTC+02:00] - Ceuta (CEST/CET)
[UTC+02:00] - Madrid (CEST/CET)
[UTC+02:00] - Paris (CEST/CET)
[UTC+02:00] - Rome (CEST/CET)
[UTC+02:00] - Stockholm (CEST/CET)
...

Either way, if you create a small modification package, you can do what you want using the integrate_metazones hook in Subs-Timezones.php.

If you prefer Option 1, then your hooked function should look something like this:
function alternative_metazones(&tzid_metazones, $when)
{
    global $tztxt;

    $tztxt['generic_timezone'] = '%1$s';
    $tzid_metazones = array();
}

If you prefer Option 2, then your hooked function should look something like this:
function alternative_metazones(&tzid_metazones, $when)
{
    global $tztxt, $txt;

    $tztxt['generic_timezone'] = '%1$s';

    foreach (timezone_identifiers_list() as $tzid) {
        $tzid_metazones[$tzid] = $tzid;

        if (isset($txt[$tzid]))
            $tztxt[$tzid] = $txt[$tzid];
    }
}
I promise you nothing.
Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

wintstar

Sorry for the late reply. The 2nd option is exactly what I was looking for. Thanks a lot
Regards Stephan

,,In order for the possible to come into being, the impossible must be attempted again and again."
Hermann Hesse (1877-1962)

My HomepageMy Board - My Atelier

Advertisement: