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

Loading holidays from yml file does not work #4

Closed
gama opened this issue Oct 25, 2010 · 10 comments
Closed

Loading holidays from yml file does not work #4

gama opened this issue Oct 25, 2010 · 10 comments

Comments

@gama
Copy link

gama commented Oct 25, 2010

There's a set of enclosing parentheses missing in file lib/business_time/config.rb, line 50. As is, I get TimeZone objects:
prompt$ script/runner 'puts BusinessTime::Config.holidays.collect(&:to_s)'
(GMT-05:00) Eastern Time (US & Canada)
(GMT-05:00) Eastern Time (US & Canada)
...

Changing the line to "(Time.zone ? Time.zone.parse(holiday) : Time.parse(holiday))", it works fine:
prompt$ script/runner 'puts BusinessTime::Config.holidays.collect(&:to_s)'
2010-01-01 00:00:00 -0500
2010-01-18 00:00:00 -0500
...

@ghost
Copy link

ghost commented Jun 9, 2011

Or even
self.holidays << (Time.zone ? Time.zone.parse(holiday.to_s) : Time.parse(holiday.to_s))
if the YAML parser already created a Date object.

atonse added a commit to abatish/business_time that referenced this issue Sep 14, 2011
@tomblomfield-zz
Copy link

I've also spotted this issue on 0.3.1..

@atonse
Copy link

atonse commented Nov 15, 2011

Tom, if you aren't able to access my pull request (as it's made from a private repo), I can send you a patch.

@tomblomfield-zz
Copy link

I'll just access the patch from your repo at;

git://github.com/abatish/business_time.git

Thanks!

@zealot128
Copy link

thx atonse, now seems to work with git repos

@bokmann
Copy link
Owner

bokmann commented Feb 6, 2012

Is this still a concern? I recently accepted several pullups and I'm not sure if I should close this issue.

@AdnanTheExcellent
Copy link

This is still a problem. I added business_time to my rails server today and was wondering why i was getting TimeZone objects as my holidays and came across this issue.

@AdnanTheExcellent
Copy link

I ended up making these changes for it to work. Parsing the holidays as times does nothing, seeing as they need to be dates. Even the example in the readme shows them to be dates, so I'm not sure why they are created as times in config file.

lib/business_time/config.rb:

change

75 Time.zone ? Time.zone.parse(holiday) : Time.parse(holiday)

to

75 Date.parse(holiday)

@tiagoblackcode
Copy link
Contributor

This issue is still present. I've forked the repo, fixed it and submitted a pull request using the suggestion made by gama.

offtopic: It's worth to say somewhere in README or even in the bussines_time.yml template that it is possible to add year agnostic dates to the holidays. i.e. 4th of July is a holiday which happens every year, and not only in 2010 as you wrote down in yml file.

@hmarr
Copy link
Collaborator

hmarr commented Jul 9, 2012

This should be fixed by #18, let me know if you have any more problems,

@hmarr hmarr closed this as completed Jul 9, 2012
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

8 participants