-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Intl] Add Timezones #28831
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Intl] Add Timezones #28831
Conversation
note im not yet convinved about form type integration... if we go that way, we might want an option The intl variant IMHO should include, and be sorted by offset, from here we also see a different format |
This PR was merged into the 4.2-dev branch. Discussion ---------- [Form] Deprecate TimezoneType regions option | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | yes | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #28848 | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> I know i've added this option myself in 4.1, but given my recent development for #28624 i realized it's an opinionated feaure, which can/should be solved on user-side (`choice_filter/choice_loader` and/or `group_by`). - blocks translations as we dont have them (see #28831) - blocks possibility of switching to Intl zones which doesnt really have this filter feature (see #28836) ~While at it, i solved a few issues with `OptionsResolver` that is able to deprecate options as of 4.2 also.~ Fixed in #28878 - when resolved trigger the deprecation - allow to opt-out from triggering the deprecation - dont trigger deprecation for default values (only given ones) Commits ------- 5cb532d [Form] Deprecate TimezoneType regions option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Once PR rebased and remaining comment addressed
ill rebase and compile the full list tomorrow. Meanwhile, can we decide on #28846 Not sure we want to add the boilerplate classes now, only to deprecate them later again. |
} | ||
|
||
if (null === $city && 0 !== strrpos($zone, 'Etc:') && false !== $i = strrpos($zone, ':')) { | ||
$city = str_replace('_', ' ', substr($zone, $i + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i need to check if this fallback is still needed. Ive added the root bundle fallback above later, and AFAIK it makes this one redundant.
status: needs work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future reference, this solves
- "Africa\/Abidjan": "Greenwich Mean Time (Abidjan)",
- "Africa\/Accra": "Greenwich Mean Time (Accra)",
- "Africa\/Addis_Ababa": "East Africa Time (Addis Ababa)",
- "Africa\/Algiers": "Central European Standard Time (Algiers)",
+ "Africa\/Abidjan": "Greenwich Mean Time",
+ "Africa\/Accra": "Greenwich Mean Time",
+ "Africa\/Addis_Ababa": "East Africa Time",
+ "Africa\/Algiers": "Central European Standard Time",
i think it's more explicit to always include the example city (ec
), and i believe for these cases when it's not provided by intl we can infer it from here.
src/Symfony/Component/Intl/Data/Generator/ZoneDataGenerator.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Intl/Data/Generator/ZoneDataGenerator.php
Outdated
Show resolved
Hide resolved
@ro0NL up to rebase and address any remaining comment? |
@nicolas-grekas i've refigured out how the compile process went, and added a binary for it as such. Works for me :) Please validate. Need to solve remaining comments still, but compiling is fast at least now :) |
This PR was merged into the 3.4 branch. Discussion ---------- [Intl] Add compile binary | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | no-ish | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> Compile the Intl data by invoking a single command, and make it work out-of-the-box. (Split from #28831) ```bash $ src/Symfony/Component/Intl/Resources/bin/compile ``` run in repository root because of https://github.com/symfony/symfony/blob/b7e798ef745a09ca2e76fba4afad0a04fcbd9195/src/Symfony/Component/Intl/Data/Generator/LocaleDataGenerator.php#L141 3.4 is ok, 4.2 is not because of #28833 but new locales are introduced in https://github.com/symfony/symfony/pull/28977/files#diff-f52da32e1ee6b93598814090d0749aa6R1 So as long as 3.4 is supported, but branches above add filters etc. during generation we're risking this discrepancy. I suggest after merge in upper branches to re-run `compile` (potential for automating, but run if needed :)) Commits ------- 426b92f [Intl] Add compile binary
Should be rebased and finished as soon as #28846 is merged IMO. |
src/Symfony/Component/Intl/Data/Provider/TimezoneDataProvider.php
Outdated
Show resolved
Hide resolved
This PR was squashed before being merged into the 4.3-dev branch (closes #28846). Discussion ---------- [Intl] Simplify API | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #18368 | License | MIT | Doc PR | symfony/symfony-docs#11221 Simplifies the Intl API. It greatly reduces the no. of boilerplate classes in this component. Very over complicated, much wow :) Solving (IMHO): ```php class LanguageBundle extends LanguageDataProvider implements LanguageBundleInterface ``` Which seems very over complicated just to provide static data. ```php // before Intl::getLanguageBundle()->getLanguageName() // string | null // after Languages::getName() // string Languages::exists() // bool ``` I left out Canonicalization on puropose, that's a new topic to me. - [x] Languages - [x] Locales - [x] Currencies - [x] Regions - [x] Scripts - [ ] Timezones (#28831) - [x] Update constraints - [x] Update form types Thoughts? Commits ------- d6b67d4 [Intl] Simplify API
Hm right, i felt awkward about a possible double As a plain list, without any context, i chose to avoid this duplication by using For the form, an alternative approach is to use optgroups per offset. Semantically (for JS & co) that might be more useful even. Havent come to play around with this though. |
compiled the TZ offsets :) |
hm shouldn't the offset be based on DST too? |
hm yes :) but we need a local time for that. Something like https://3v4l.org/57U2J could be taken into account in status: needs work |
@Hanmac i've removed the last commit, i dont think we need to compile offsets and instead simply use status: needs review (still ready :)) |
@ro0NL Question about the Translation: i saw in the german translation something about normal time, but isn't that wrong for DST and should it say summer time instead? maybe instead of going directly from DateTimeZone "Europe/Berlin" to Translation, maybe instead use https://github.com/unicode-org/icu/blob/master/icu4c/source/data/zone also has different lables for that |
@Hanmac i checked the google widget again :) today it includes
(in english so per https://github.com/unicode-org/icu/blob/78a4abc5ed5db9ddadb57dca0f5222e7639c124c/icu4c/source/data/zone/en.txt#L292-L295 it seems to always pick I interpreted these codes as
Symfony now follows So using IMHO using the generic name solves the issue of names varied based on local time, thus a more simple implementation 👍 (the offset should be dynamic and is a display/rendering concern for now - unrelated here) status: needs work |
the Translations are in the Meta like de used for CET or MEZ i think it is okay for now if the name you show is DST independent. I think what the pro way would be:
do you need to parse the abbr? i currently don't know what the best way would be there |
@Hanmac can you check once more :) the fallback for de.json currently is
Yes https://github.com/unicode-org/icu/blob/30d203459720bb64c850680a79b0f393a60934ca/icu4c/source/data/misc/metaZones.txt#L3553-L3557 gives us europe/berlin > Europe_Central https://github.com/unicode-org/icu/blob/30d203459720bb64c850680a79b0f393a60934ca/icu4c/source/data/zone/de.txt#L1512-L1514 gives us Europe_Central > lg (Mitteleuropäische Zeit)
agree :)
agree :)
again, not sure how the abbr. is related... |
to clarify, Symfony |
I think i understand, Still, for the name itself, it's just another fallback. We only provide the long generic name for now. |
Thank you @ro0NL. |
This PR was squashed before being merged into the 4.3-dev branch (closes #28831). Discussion ---------- [Intl] Add Timezones | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | replaces #26851, #17628, #17636 | License | MIT | Doc PR | symfony/symfony-docs#11447 This PR compiles a new `TimezoneBundle` from ICU data, based on the following resources: - https://github.com/unicode-org/icu/tree/master/icu4c/source/data/zone - https://github.com/unicode-org/icu/blob/master/icu4c/source/data/misc/timezoneTypes.txt - https://github.com/unicode-org/icu/blob/master/icu4c/source/data/misc/metaZones.txt The goal is to provide a fixed set of timezones, with a localized human readable name. For inspiration and to double check some data i used the timezone widget from google, e.g. when using Google Calendar. I've only pushed some common compiled locales for review, the rest will follow once finished. cc @jakzal Commits ------- 4bea198 [Intl] Add Timezones
This PR was merged into the 4.3-dev branch. Discussion ---------- [Validator] Allow intl timezones | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | ref #28836 | License | MIT | Doc PR | symfony/symfony-docs#11502 This PR considers the ICU timezones (#28831) as valid, as well as the PHP ones. Both can be used in `DateTimeZone`, but expired timezones cannot be used with `IntlTimeZone`. The `intlCompatibility` option ensures compatibility between both. Practically this allows for both `UTC` and `Etc/UTC`, where the latter should be preferred. I.e. currently `Etc/UTC` is considered an invalid timezone ... which it's not. Commits ------- 7294b59 [Validator] Allow intl timezones
This PR compiles a new
TimezoneBundle
from ICU data, based on the following resources:The goal is to provide a fixed set of timezones, with a localized human readable name.
For inspiration and to double check some data i used the timezone widget from google, e.g. when using Google Calendar.
I've only pushed some common compiled locales for review, the rest will follow once finished.
cc @jakzal