- Issue created by @pameeela
- π©πͺGermany jurgenhaas Gottmadingen
This should be possible with a little tweak of core. It already gathers the host's default timezone in
\Drupal\Core\Installer\Form\SiteConfigureForm::buildForm
:$default_timezone = $this->config('system.date')->get('timezone.default') ?: @date_default_timezone_get(); $form['regional_settings']['date_default_timezone'] = [ '#type' => 'select', '#title' => $this->t('Default time zone'), '#default_value' => $default_timezone, '#options' => TimeZoneFormHelper::getOptionsListByRegion(), '#weight' => 5, '#attributes' => ['class' => ['timezone-detect']], '#access' => empty($install_state['config_install_path']), ];
That assumes that the correct timezone is set on the host, but I mean that's what we should expect. If not even that is configured correctly, there's hardly anything one can do.
Now, this approach in core only works if the config form is opened and saved.
This should instead be done during installation. Then we should get the correct time zone for "most" new installations.
- π¦πΊAustralia pameeela
The only problem with using the host is that for the trial it would be the trial host, which I assume is probably just the US. This may just be something we have to live with but worth considering, in case we would rather ask the user to select it.
- πΊπΈUnited States phenaproxima Massachusetts
Idea: what if we changed the installer such that:
- Turned the timezone selection into a hidden field, whose default value is the server-detected timezone
- Use some JavaScript to ask the browser what timezone it is, and update the value of that hidden field
- Set Drupal's timezone to whatever that hidden field submits
- π¦πΊAustralia pameeela
That sounds great if we can swing it! But, this only works if we keep the onboarding as a pre-install step, and I think we have decided to decouple it to allow pre-installing, right?
In that case, it's tricky because we also default to users can select their own timezone. This means that even if you update the site timezone, user 1 (or any other users who already exist before it is changed) are still set to UTC.
- πΊπΈUnited States phenaproxima Massachusetts
So it turns out that core already implements automatic client-size timezone detection, as proposed in #4. The only difference is that it shows the user a select field in a fieldset, so all we need to do is make that a hidden field, which is what my MR does.
This is squarely ready for review.
- πΊπΈUnited States thejimbirch Cape Cod, Massachusetts
Looks good. Marking as RTBC
-
thejimbirch β
committed 0bde9c66 on 1.x authored by
phenaproxima β
Issue #3486883 by phenaproxima, pameeela: Set timezone from browser...
-
thejimbirch β
committed 0bde9c66 on 1.x authored by
phenaproxima β
- πΊπΈUnited States thejimbirch Cape Cod, Massachusetts
Merged, thanks everyone!
-
phenaproxima β
committed 6c623d83 on 1.0.x
Issue #3486883 by phenaproxima, pameeela: Set timezone from browser...
-
phenaproxima β
committed 6c623d83 on 1.0.x
Automatically closed - issue fixed for 2 weeks with no activity.