stub42 / pytz

pytz Python historical timezone library and database
MIT License
353 stars 93 forks source link

Missing countries according to #123

Closed detrin closed 2 months ago

detrin commented 5 months ago

There is another package https://github.com/deactivated/python-iso3166 for and using example

from iso3166 import countries
from pytz import country_timezones

for country in countries:
    numeric = country.numeric
    alpha2 = country.alpha2
    if alpha2 not in country_timezones:
        print(country)
    else:
        timezone = country_timezones[alpha2]

we get

Country(name='Bouvet Island', alpha2='BV', alpha3='BVT', numeric='074', apolitical_name='Bouvet Island')
Country(name='Heard Island and McDonald Islands', alpha2='HM', alpha3='HMD', numeric='334', apolitical_name='Heard Island and McDonald Islands')
Country(name='Kosovo', alpha2='XK', alpha3='XKX', numeric='983', apolitical_name='Kosovo')

Kosovo is a mistake in python-iso3166 since it is not in https://en.wikipedia.org/wiki/ISO_3166-1 so disregard this example. I opened an issue in the package for that. https://github.com/deactivated/python-iso3166/issues/37

I could open a PR and I could try prepare github action for checking the wiki for ISO

detrin commented 5 months ago

I prepared a repo where you can use the CLI to fetch the newest ISO 3166 list or use the countries.json file. https://github.com/detrin/download-iso3166-list

mjpieters commented 2 months ago

Kosovo is a mistake in python-iso3166 since it is not in https://en.wikipedia.org/wiki/ISO_3166-1 so disregard this example.

I would dispute that is a mistake. ISO 3166 allows for user-assignments for x codes, and so xk is compliant, plus it's the defacto country code until specific UN publications list Kosovo, and currently used by a significant number of international organisations.

detrin commented 2 months ago

@mjpieters well, if it would be presented this way in the README of the repo that it is xk is compliant, I have no issue with that.

stub42 commented 2 months ago

This data is from the IANA timezone database, and changes need to happen there. pytz just provides access to the database.