Coder Social home page Coder Social logo

Getting the name of a region about holidays HOT 4 OPEN

holidays avatar holidays commented on June 21, 2024
Getting the name of a region

from holidays.

Comments (4)

ppeble avatar ppeble commented on June 21, 2024

Hi @samstickland! Sorry for the delay, had a busy week.

Currently I don't think we can give you what you seem to need. All I can give you at the moment is a list of all of the regions we have available:

Holidays.load_all
Holidays.regions # <- returns an array of all available region symbols (i.e. :gb, :us, etc)

This isn't exactly what you want but currently we don't map an English name, let alone a i18n'ed name. That'll have to be something we add.

As to your second point, the issue is that :gb is an overall 'parent' (for lack of a better term) region. Really :gb_con should be a sub-region of :gb_eng, if I understand correctly (I'm American so I might have my names/regions wrong).

I'll need to think about this as well, as I can definitely see a use for it but up to this stage we haven't needed to do it. In our current nomenclature we would want to do something like :gb_eng_con to indicate that 'Cornwall' belonged as a sub-region of :gb_eng but I don't think our current logic will allow that.

These are a reasonable requests. I'm going to leave this open as a feature request and work on it in the near future, I think it's doable. No timeframe at this time, though.

from holidays.

jlsync avatar jlsync commented on June 21, 2024

If you have the countries gem installed then you can do something like this...

Holidays.available_regions.sort.uniq.map{|r| 
   ISO3166::Country[r] ? [ ISO3166::Country[r].name , r ] : nil }.compact.sort_by{|a| a[0]}

=> [["Argentina", :ar], ["Austria", :at], ["Australia", :au], .....

BTW, 'Christmas Day' does not seem to be listed as a holiday for Australia (:au).

from holidays.

ppeble avatar ppeble commented on June 21, 2024

@jlsync Hm, interesting! Unfortunately one problem is that not all of our regions are currently ISO compatible, I don't think. Since I've taken over any new regions must be and I've been correcting them as I've found issues but I would have to do an audit to figure out which ones are 'incorrect' currently. Still a good option to have, though. Thank you!

To your second point, bah! I missed this in past refactorings. I'm going to create another issue so I don't lose track of it. Thank you!

from holidays.

martingjaldbaek avatar martingjaldbaek commented on June 21, 2024

I went through the symbols and found the names for each of them and put them in a hash in this gist. (It's already slightly out of date with the latest changes to the definitions from a month ago but should be quite fast to clean it up).

A bit of feedback about things I discovered while going through the list:

Duplicates

  • Isle of Man is listed as both :im and :gb_iom (seems to be on purpose, not sure why)
  • :es_v (Valencia) and :es_vc (Valencian Community) encode the same data as well
  • (Maybe in case there's ever another refactor, aliases could be supported, so a region can have multiple names and codes, but there's also a way to get a listing without duplication?)
  • Localisation has somehow snuck its way in as separate symbols for a couple of countries, Belgium and Bulgaria, with the symbols :be_fr, :be_nl, and :bg_bg, :bg_en even though they (as far as I can tell) encode exactly the same holidays.

Very detailed sub-regions and organizations

  • Not a bug per se, but at least for my use cases I don't want to ask my users if they come from Northern or Southern Tasmania (au_tas_north and au_tas_south) - if the level of detail you care about is only country and state, but not further down than that, then stick to only the :xx and :xx_xx symbols, but leave out the xx_xx_xx
  • Similarly, if a user only wants geographic regions, then they manually have to leave out all the organisation symbols like :nyse (New York Stock Exchange), ecb_target (European Central Bank) and similar. Some kind of categorization of the symbols, so a user of the gem could ask for e.g. 'countries', 'regions', 'sub-regions', 'organizations' separately would be nice.

from holidays.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.