News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

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 view this attachment.
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?
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"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

#3
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

jsx

Hi @Sesquipedalian

I also thought that I would like to have Warsaw entered here.

[UTC+02:00] - Berlin, Büsingen, Paris, Rome, Madrid, etc. (CEST/CET)

So how can I do that in this code? How to add the city of Warsaw?

Sesquipedalian

Set the "Show time zones from these countries first" setting to "PL".
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

jsx

@Sesquipedalian

I forgot about this post. So now I answer.

In one post you gave the codes, but it's not easy, because to enter one or the other code to Subs-Timezones.php I need to find out how to insert the hook, right? So I have to read about it here?

https://wiki.simplemachines.org/smf/Integration_hooks

Sesquipedalian

Follow these steps to accomplish what you want, @jsx:

  • Download and install wintstar's mod.
  • Open the mod's PHP file in a text editor.
  • Inside the PHP file, find the priority_timezones_plus_metazones() function and change the code inside it to match what I posted as "Option 1" above. (Don't change the name of the function, just the code inside it.)
  • In the SMF admin control panel, set the "Show time zones from these countries first" setting to "PL".

That should produce exactly the output you want.
I promise you nothing.

Sesqu... Sesqui... what?
Sesquipedalian, the best word in the English language.

jsx

I had no idea @wintstar made such a mod. Everything is clear to me now. Thanks for the help.


Advertisement: