-
Notifications
You must be signed in to change notification settings - Fork 215
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
Holidays not working when config.time_zone is changed in application.rb #36
Comments
Anyone? Are holidays working for everyone else? I don't really see how I'm doing anything wrong with configuring the holidays for it to be an issue on my end, but if it is, i'd be glad to know what I'm doing wrong. |
Adnan: date = Date.parse(2013, 05, 27)
Time.workday?(date) |
@marshallshen : This is the output from my rails console: 1.9.3p327 :003 > date = Date.parse('2013/05/27') |
Ok, so i figured out what the issue is. business_time holidays seems to fail when the rails time zone is not set to UTC. I currently have this line in my application.rb:
When i comment this out, the holidays work. However, i need to keep that as my time zone. This gem says that's its timezone agnostic so I'm going to assume this is a bug. |
OK, i dug through the code deeper and found the issue. My holidays seem to be storing in BusinessTime::Config.holidays as TimeWithZones on initialize instead of Dates. I am using the default initializer with the code:
and business_time.yml file is shown in my first post. When i update my /initializers/business_time.rb file to:
the holidays are stored as Dates and everything works as planned. |
I agree, sounds like a bug. Can you write a test to expose it or better yet, include a fix in a pullup request? |
@AdnanTheExcellent's solution solved the problem here. |
Ok, I'm prepping for a new release this weekend, and this is top of my list. We put a lot of work into dealing with timezones... It is said that every software engineer eventually learns to hate timezones, and this proves that point |
Awesome. Glad this is going to get patched up in a more elegant solution than what i did. |
…Ensure we wind to beginning of business day when using business_hours before/after methods
I am using the business time gem and it seems that holidays are not being accounted for. Here's an example of what my config looks like and some console outputs.
/config/business_time.yml:
in Rails console:
it clearly shows may 27th as a holiday, yet it chooses may 27th as a viable business day. Same with July 4th.
I don't think its a timezone issue because july 3rd and july 5th don't trigger as a holiday either.
My project gem specs:
ruby 1.9.3p327
rails 3.2.11
business_time 0.6.1
EDIT:
it seems that updating the config.time_zone in application.rb is causing the issue. FOr instance, if i set:
then business_time holidays fail.
The text was updated successfully, but these errors were encountered: