Giter VIP home page Giter VIP logo

Comments (9)

AdnanTheExcellent avatar AdnanTheExcellent commented on August 15, 2024 1

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:

BusinessTime::Config.load("#{Rails.root}/config/business_time.yml")

and business_time.yml file is shown in my first post.

When i update my /initializers/business_time.rb file to:

BusinessTime::Config.load("#{Rails.root}/config/business_time.yml")
BusinessTime::Config.holidays = BusinessTime::Config.holidays.map(&:to_date)

the holidays are stored as Dates and everything works as planned.

from business_time.

AdnanTheExcellent avatar AdnanTheExcellent commented on August 15, 2024

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.

from business_time.

marshallshen avatar marshallshen commented on August 15, 2024

Adnan:
In Rails console, run the following, does it return false?

date = Date.parse(2013, 05, 27)
Time.workday?(date)

from business_time.

AdnanTheExcellent avatar AdnanTheExcellent commented on August 15, 2024

@marshallshen : This is the output from my rails console:

1.9.3p327 :003 > date = Date.parse('2013/05/27')
=> Mon, 27 May 2013
1.9.3p327 :004 > Time.workday?(date)
=> true
1.9.3p327 :005 > BusinessTime::Config.holidays
=> [Mon, 18 Feb 2013 00:00:00 PST -08:00, Mon, 27 May 2013 00:00:00 PDT -07:00, Thu, 04 Jul 2013 00:00:00 PDT -07:00, Mon, 02 Sep 2013 00:00:00 PDT -07:00, Thu, 28 Nov 2013 00:00:00 PST -08:00, Fri, 29 Nov 2013 00:00:00 PST -08:00, Wed, 25 Dec 2013 00:00:00 PST -08:00, Tue, 31 Dec 2013 00:00:00 PST -08:00, Wed, 01 Jan 2014 00:00:00 PST -08:00]

from business_time.

AdnanTheExcellent avatar AdnanTheExcellent commented on August 15, 2024

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:

config.time_zone = 'Pacific Time (US & Canada)'

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.

from business_time.

bokmann avatar bokmann commented on August 15, 2024

I agree, sounds like a bug. Can you write a test to expose it or better yet, include a fix in a pullup request?

from business_time.

leods92 avatar leods92 commented on August 15, 2024

@AdnanTheExcellent's solution solved the problem here.
I'm using a different default time_zone as well.

from business_time.

bokmann avatar bokmann commented on August 15, 2024

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

from business_time.

AdnanTheExcellent avatar AdnanTheExcellent commented on August 15, 2024

Awesome. Glad this is going to get patched up in a more elegant solution than what i did.

from business_time.

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.