moment-timezone icon indicating copy to clipboard operation
moment-timezone copied to clipboard

Add full country name

Open abdullah2993 opened this issue 3 years ago • 3 comments

Moment-timezone version which you use:

Version: 0.5.34

Issue description:

At the moment(no pun intended) only country code is available via timezone. It would be nice to have country name also available.

abdullah2993 avatar Jan 06 '22 13:01 abdullah2993

Moment Timezone gets its underlying data from the IANA time zone database, which only provides the two-letter ISO codes for countries.

Getting the full country name data into Moment Timezone would require integrating another data source, such as the Unicode Common Locale Data Repository (CLDR). This is not a simple task, and it's likely way out of scope for the maintenance-only status of this project. Part of the problem is translations and locales, because there would need to be a full list of country names for each different locale.

gilmoreorless avatar Jan 23 '22 09:01 gilmoreorless

it appears that the data is already available here

abdullah2993 avatar Jan 24 '22 13:01 abdullah2993

Ah yes, I'd missed that, good point! But it still doesn't solve the locale problem. For example, if a user runs moment.locale('es'), then calls an API that returns a country name and gets "United States" instead of "Estados Unidos", that's going to cause confusion.

Even the existing English-language names in that data file are inconsistent with official naming conventions (e.g. "Congo (Dem. Rep.)" instead of "DR Congo" or "Democratic Republic of the Congo".)

gilmoreorless avatar Jan 25 '22 04:01 gilmoreorless

@abdullah2993 as part of the moment-timezone release (the code), the data and the metadata is also released. So you're free to pick whatever suits your needs from the data/metadata directly.

Also you could use the "source" data from tzdata (not official) or the CLDR data that @gilmoreorless pointed out (more official, also available in all languages).

It's called moment-timezone not country-code-to-name for a reason.

ichernev avatar Aug 25 '22 12:08 ichernev