Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
When going to admin/config/regional/settings (or picking a timezone in a user profile), America/Montreal is missing from the list.
Proposed resolution
Add a hook to allow modules to alter the displayed list of time zones. #32
Switch to DateTimeZone::ALL_WITH_BC constant which adds 60 legacy(?) timezones including America/Montreal.
Remaining tasks
Decide if adding a hook is needed.
User interface changes
none
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#26 | selecting-america-montreal.png | 1.33 MB | Tom M Fallon |
#26 | successfully-installed-site.png | 52.35 KB | Tom M Fallon |
#26 | regional-settings-successfully-saved.png | 45.67 KB | Tom M Fallon |
#25 | america_montreal_and-2530306-25.patch | 670 bytes | Pavan B S |
#6 | Screen Shot 2015-07-09 at 7.51.01 PM.png | 104.79 KB | cilefen |
Comments
Comment #1
cilefen CreditAttribution: cilefen commentedDrupal uses timezone_identifiers_list() to enumerate the timezones.
I think this may be a PHP bug:
The output does not contain Montreal for me on PHP 5.6.10.
See also https://core.trac.wordpress.org/ticket/26656
https://answers.launchpad.net/ubuntu/+source/tzdata/+question/239234
If you could, please open a PHP bug ticket on timezone_identifiers_list() and link it here.
Comment #2
bohemier CreditAttribution: bohemier commentedHi cilefen,
Thanks for checking this. You are right, php does not return the Montreal Timezone. It seems this is due to some IANA changes, making America/Montreal a linked timezone to America/Toronto (same goes for Asia/Istambul). From what I understand DateTimeZone::listIdentifiers (the function called by timezone_identifiers_list) does not return aliases when called with no parameters. The last comment on https://bugs.php.net/bug.php?id=66102 ([2014-08-11 14:53 UTC] a dot servedio at technotraffic dot com) explains it well. Strange that linked timezones end up in the "Backwards compatible" list when they are still valid timezones...
I think this raises usability issues for users looking to set their timezones in their profile since they are still valid timezones. I wonder if the locale module should fetch the whole list instead via the ALL_WITH_BC flag?
It would add 160 more timezones to the list. It does not seem such a big overhead...
Comment #3
bohemier CreditAttribution: bohemier commentedComment #4
cilefen CreditAttribution: cilefen commentedNow that is another thing altogether. Drupal 8 is probably the same so we have to fix it there first.
Comment #5
cilefen CreditAttribution: cilefen commentedComment #6
cilefen CreditAttribution: cilefen commentedWith #5:
Comment #7
bohemier CreditAttribution: bohemier commentedThanks cilefen, this works well for me in latest 8.0.x-dev. I was able to select America/Montreal in both the system timezone and my user profile.
Comment #8
jabberwooki CreditAttribution: jabberwooki commentedThe patch #5 works well for me on the latest 8.0.0-dev git cloned version (system and user timezone).
Comment #9
pandaski CreditAttribution: pandaski at XiNG Digital commented#5 works well for me. Finally I can see Australia/Canberra now, thanks for it.
Comment #10
pandaski CreditAttribution: pandaski at XiNG Digital commentedComment #11
alexpottSo... following the links on https://bugs.php.net/bug.php?id=66102 and looking at https://github.com/eggert/tz/commit/242980fc79ef5fb676383f91505f9cbce6ff...
Why doesn't that apply to Drupal?
Comment #12
bohemier CreditAttribution: bohemier commentedIt seems to me that America/Montreal has always been a valid timezone...
"America/Montreal is a time zone identifier in the IANA time zone database...." https://en.wikipedia.org/wiki/America/Montreal
Whether or not it is incorrectly linked to America/Toronto is not quite as important as the fact that end users end up searching for missing timezones...
The question is: Should we load the extra 160 entries in the timezone selection to provide a better user experience, and is there a problem in doing so?
Thanks!
Comment #16
wturrell CreditAttribution: wturrell as a volunteer commentedI think this is OK, but it may need sign-off from someone (who?)
Note the patch is not hardcoded to one country, despite the name. What we're doing is calling timezone_identifiers_list(), which is an alias of DateTimeZone::listIdentifiers(), with the 'ALL_WITH_BC' constant rather than the default 'ALL', where 'BC' = backwards compatible.
- Can reproduce original problem - America/Montreal missing from timezone list.
- Fixed by patch (applies cleanly to 8.3.x)
- Single line patch with no coding issues.
- I assume this doesn't merit a change record as it's merely adding extra options, not altering any existing settings
- Note the patch now increases the list from 417 to 474 options - i.e. 57 changes, so either it's been pruned or the ref to 160 in #2 was a typo. [Edit - see comment #19 - the exact length depends on PHP version and DB used, and the 100 or so missing is because ignore lots of abbreviations etc. that aren't in the Continent/City format]
- To the best of my knowledge, this would, in core, affect: the site regional setting (on install and in config), individual user timezones and the Date field widget ("time zone override")
- Issue summary updated
Comment #17
alexpottFrom the wikipedia article. We need to know the pros and cons of using a list with BC. The pro has been stated as UX but what about interoperability with systems that don't use a BC list?
Comment #18
bohemier CreditAttribution: bohemier commentedSince PHP (as well as others) has native support for the BC entries, I wouldn't expect much interoperability problems in that respect.
Comment #19
wturrell CreditAttribution: wturrell as a volunteer commentedYep, in PHP you can load the backward compatible ones regardless:
and it looks to me like they're giving correct timestamps (i.e. matching Toronto and Sydney respectively.)
If you supply a nonsense timezone it returns false, as does a partial match - e.g. America/M - just to rule out any pattern matching.
Likewise Unix seems to support the extended list:
That thing I mentioned about 57 versus 160 more timezones? It's because we have a hardcoded regexp matching the continents and UTC:
if (preg_match('!^((Africa|America|Antarctica|Arctic|Asia|Atlantic|Australia|Europe|Indian|Pacific)/|UTC$)!
and the full contains loads of stuff like:
Also my test servers have marginally different versions of PHP 7 - one of which has a few more options that the other.
Comment #20
alexpottSo #19 suggests that the BC list is different between different versions of PHP - what does this mean for database transportability? What happens if a user that selects a timezone that exists and then the PHP version changes?
Comment #21
wturrell CreditAttribution: wturrell as a volunteer commentedSome further info (I'm not proposing a solution btw, nowhere near enough experience):
PHP uses the "Olson" timezone DB (the IANA one). Supposedly, you can add this PECL extension if you're unable to upgrade PHP itself.
There's a function
timezone_version_get()
to see which DB version you have (its on phpinfo() as well).Versions numbering is year.release - e.g.
version_compare('2016.1','2016.10');
would tell you which was more recent.I've not investigated whether timezones are ever removed from the DB / how they maintain backward compatibility.
Comment #22
mpdonadioI'm neutral to negative on the current solution.
Have we surveyed other systems as to whether they use the BC list or not?
I am also concerned about the scope of this issue. The bug report is that 'America/Montreal' isn't listed because of bug in the IANA tzdata, but the solve is to add in all of the BC zones.
I am not sure if adding BC is proper. What are we being BC with? This shouldn't be about convenience, but true backwards compatibility.
On one hand, people shouldn't be using BC for a new install; there is nothing to be BC with. On the other hand, BC may be beneficial when the TZ identifier is used to communicate with an outside system (but I think that the TZ offset for a particular date/time is the more common case, eg ISO string).
I think we should consider two options.
1. Maintain a list of "extra" timezones that we merge into `\DateTimeZone::listIdentifiers(\DateTimeZone::ALL)` to account for bugs in tzdata. And yes, I would really like to get rid of that global function. For this I would propose creating a DateTimeZonePlus class that extends \DateTimeZone to parallel DateTimePlus that has this functionality. And then, replace timezone_identifiers_list() with `DateTimeZonePlus::listIdentifiers()` (this idea is still a bit half-baked, not at peak caffeine load yet).
2. Have a checkbox on install and/or a setting that would enable using \DateTimeZone::ALL_WITH_BC.
They may not be mutually exclusive.
Of those, I prefer #1.
Comment #23
wturrell CreditAttribution: wturrell as a volunteer commented@mpdonadio:
Neutral questions/observations:
- do we want another list to maintain ourselves? Arguably there are benefits for our list of countries, where we've shortened some of the more clunky ISO names, is same applicable to timezones? e.g. how many "bugs in tzdata" are there likely to be? would we have to monitor all changes to daylight savings dates as well?
- I like the (apparent) simplicity of #2, but, as you say, they need not be mutually exclusive.
- any setting should clearly be off by default, however people have to specify the site's timezone on installation, before they get a chance to adjust the config setting
- how many sites does this actually affect anyway - is it worth the effort (i.e. is it an inconvenience "I wish my city was on this list rather than [some other place]", or a bug "this missing timezone causes a problem with my client's site because...")
- For #1, are you suggesting deprecating system_time_zones() and removing in 9.0.0, or just changing what it wraps around?
- consensus here seems to be BC could be risky, imho doesn't seem a bad thing to give people a choice
Comment #24
mpdonadioFrom https://github.com/eggert/tz/blob/master/northamerica#L1416-L1430
America/Montreal is not in the latest version of zone.tab. It is also not different on http://www.nrc-cnrc.gc.ca/eng/services/time/time_zones.html or http://www.nrc-cnrc.gc.ca/eng/services/time/faq/index.html#Q5 (my RASC handbook lists these as the definitive references for Canada). I would follow those sources over the current Wikipedia article.
Based on this, I am not convinced we have an actual problem to solve.
Comment #25
Pavan B S CreditAttribution: Pavan B S at Valuebound commentedRe rolled the patch and applied, Please review.
Comment #26
Tom M Fallon CreditAttribution: Tom M Fallon as a volunteer and at CTI Digital commentedHello
Tested #25 america_montreal_and-2530306-25.patch
1) Created a new Drupal 8.3.x site.
2) Selected America/Montreal as a timezone.
3) Clicked Save
4) Site successfully installs with no error messages & No errors in log
5) I visit /admin/config/regional/settings and see that America/Montreal is the timezone.
This appears to pass
Screens shots below showing testing
Comment #27
Tom M Fallon CreditAttribution: Tom M Fallon as a volunteer and at CTI Digital commentedComment #28
wturrell CreditAttribution: wturrell as a volunteer commentedThanks for the work, but everyone needs to re-read the issue rather than just re-rolling and approving the patch – we don't have agreement on whether (a) there is actually a problem or (b) that the patch is a suitable solution.
Comment #29
mpdonadioI am still not convinced that we have an actual problem. I am also 100% against adding the whole BC list, even if we continue to filter against the PREG above.
America/Montreal is the same as America/Toronto post-1970. The IANA list has America/Toronto in northamerica.
The BC list will do two things:
1. It will bring in the backzone data, which is a partial reconstruction of pre-1970 data. It is incomplete and changes.
2. It will bring in the backward data, which are the links to allow old names to be used in legacy systems (when location names change, when compound locations get introduced, etc).
The problem is that \DateTimeZone::listIdentifiers(\DateTimeZone::ALL_WITH_BC) does not distinguish between the two.
#1 may be a good idea for people who need pre-1970 behavior, but #2 will add duplicate entries when compound locations are in zoneinfo proper (eg, America/Indiana/Indianapolis and America/Indianapolis). The other problem is that the full zoneinfo database can very per system, depending on what version of PHP they are using (see https://3v4l.org/3sEMa) or if they have the PECL extension. There is no feasible way to maintain this in our code; we currently have a critical issue because of broken HEAD directly due to a change in zoneinfo.
You can also do a config override:
just worked for me.
This isn't about adding more cities to make things easier for people. We have issues to improve the UX of this
- #2847651: Improve timezones selector with optgroups
- #2853386: Interactive time-zone picker
The second is really worth exploring. I don't like the map idea, but would love it if we could come up with something similar to what tzselect does.
If someone thinks we have a problem, then make an Issue Summary update that describes what the problem is, and what a solution could be. Otherwise, I think this needs to be Closed (Won't Fix).
Comment #30
bohemier CreditAttribution: bohemier commentedI originally opened this issue hoping to address usability problems with the usage of timezones that recently ended up in the BC category.
which comes back to this issue: should the BC entries be selectable as valid timezones in Drupal... or not.
I don't have enough experience with Drupal core date handling to be able to make a call on this... But the patch did work for me.
Comment #31
mpdonadio@bohemier, do other systems you use have "America/Montreal" as a TZ option (the IANA name), not just "Montreal, Canada?" (the nearest city)?
Comment #32
mpdonadioAnother possible solve here is to allow contrib solutions by introducing `hook_system_time_zones_alter(&$zones)`, but that wouldn't necessarily help at the install stage.
or
Comment #33
bohemier CreditAttribution: bohemier commented@mpdonadio mainly America/Montreal, but that is less relevant from a user perspective...
I really like your idea of a system hook... It would leave core unchanged and would allow to add the missing TZ with the help of a module. Having them at install time is not that important IMO since we're mostly concerned with users being able to find their timezone when using Drupal.
So +1 for the hook...
Comment #41
quietone CreditAttribution: quietone at PreviousNext commentedI have read the Issue Summary and most of the comments and this seems like a task and not a bug.
The issue was opened to resolve usability problems with the timezone (#30), specifically that some timezones where no longer in the list. A patch was developed by later reviews raised concerns about making the change. Some are:
At the end a solution of adding a hook was agreed to but there has been no action on that in 5 years. The patch that is here add the BC list and has been rerolled a few times (even though a decision to use that approach was not yet agreed to).
Given the opposition to making this change this could be closed as works as designed. I'll ask in #bugsmash.
Comment #42
bohemier CreditAttribution: bohemier commentedI agree this should be dropped as I think we got used to the new Timezones now :)
Thanks for the followup Quietone
Comment #43
cilefen CreditAttribution: cilefen commented