Skip to content
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

UnknownRegionError fires incorrectly for non north-american regions #11

Closed
rojoko opened this issue Sep 8, 2011 · 3 comments
Closed

Comments

@rojoko
Copy link
Contributor

rojoko commented Sep 8, 2011

I run into the following problem.
The first time when I use a region outside of north-america (eg. :de , :no, :el) in a Holidays Method (Holidays.on, Holidays.between) I get a UnknownRegionError, but firing the command a second time Holidays returns the
right value.

ruby-1.9.2-p290 :017 > g = Holidays.on('2011-1-1'.to_date, :el)
Holidays::UnknownRegionError: Holidays::UnknownRegionError
from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/holidays-1.0.3/lib/holidays.rb:308:in parse_regions' from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/holidays-1.0.3/lib/holidays.rb:279:inparse_options'
from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/holidays-1.0.3/lib/holidays.rb:103:in between' from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/holidays-1.0.3/lib/holidays.rb:66:inon'
from (irb):17
from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/commands/console.rb:44:in start' from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/commands/console.rb:8:instart'
from /home/roland/.rvm/gems/ruby-1.9.2-p290@rails3tutorial/gems/railties-3.0.9/lib/rails/commands.rb:23:in <top (required)>' from script/rails:6:inrequire'
from script/rails:6:in `

'

ruby-1.9.2-p290 :018 > g = Holidays.on('2011-1-1'.to_date, :el)
=> [{:date=>Sat, 01 Jan 2011, :name=>"Πρωτοχρονιά", :regions=>[:el]}]

@alexdunae
Copy link
Contributor

I just tried this and it seemed to work.

irb(main):001:0> require 'holidays'
irb(main):002:0> require 'active_support/core_ext/string/conversions'
irb(main):003:0> g = Holidays.on('2011-1-1'.to_date, :el)
=> [{:date=>#<Date: 2011-01-01 (4911125/2,0,2299161)>, :name=>"Πρωτοχρονιά", :regions=>[:el]}]

It's a super strange error. Are you able to try it outside of the Rails console (using irb) and let me know if you get the same results?

@rojoko
Copy link
Contributor Author

rojoko commented Sep 11, 2011

It works with requiring 'holidays' and 'active_support/core_ext/string/conversions' . Thanks for your quick response.

@rojoko rojoko closed this as completed Sep 11, 2011
@alexdunae
Copy link
Contributor

Does it also work without active_support (e.g. using Date.parse instead of ''.to_date)? I want to make sure that there isn't some conflict somewhere.

Murphydbuffalo pushed a commit to Murphydbuffalo/holidays that referenced this issue Sep 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants