DaniSchenk / moment-feiertage

MomentJS Plugin: Check if a date is a german holiday (Feiertag)
https://www.npmjs.com/package/moment-feiertage
30 stars 11 forks source link

moment-feiertage does not use Google Places compliant values for states #17

Closed t-wark closed 3 years ago

t-wark commented 3 years ago

If you use the Google Places API, for the query of the federal states to determine the holidays, then you have to remap the value for Lower Saxony (NDS) to the plugin compatible value (NI).

So it would be a good idea to use the values that Google uses for administrative_area_level_1 as short_name also as check for the federal states

DaniSchenk commented 3 years ago

I see your point. Mapping is annoying and from your perspective avoidable. I took state codes from the ISO_3166-2 standard. IMHO in almost all use cases mapping is necessary. E.g. think about user interfaces - there will be a lot of different possibilities to phrase the state code BY: Bayern, bayern, bavaria, DE-BY, de-0, Weißwurst-Oase, ...

So I don't think it's expedient to include a mapping to a particular service. But you're right, Google is most likely an often used service regarding this plugin. To help others, it would be a great idea to provide a mapping to the Google Placed API. Maybe you could add them to the readme or provide them in the issue comments?

t-wark commented 3 years ago

Thank you for your fast reply. I understand your decision to use an ISO standard, rather than using service specific values. I just thought Google uses a good standard, that can be used everywhere. I will have a look for the values, that the places API returns and will add them here :)

Edit: Here is a table for the mapping Full name ISO 3166-2:DE Google Places API short_name
Baden-Württemberg BW BW
Bayern BY BY
Berlin BE Berlin
Brandenburg BB BB
Bremen HB HB
Hamburg HH HH
Hessen HE HE
Mecklenburg-Vorpommern MV MV
Niedersachsen NI NDS
Nordrhein-Westfalen NW NRW
Rheinland-Pfalz RP RP
Saarland SL SL
Sachsen SN SN
Sachsen-Anhalt ST SA
Schleswig-Holstein SH SH
Thüringen TH TH